Android Question .GetView(n) not work with customviews (CircularProgressBar)

Mike1970

Well-Known Member
Licensed User
Longtime User
Hi everyone, i've a customlistview, with custom elements.
In each element there is a CircularProgressBar, i want to incremente the value of a circularprogressbar in one element.

The code to do it:

B4X:
Public Sub AggiornaProgress(Data() As Object)
    '0 = Progress Value
    '1 = Uploaded Files
    '2 = Total Files
    '3 = Filename
        
    If Data(0) == 0 Then 'It means one file started
        For i=0 To clvFoto.Size-1
            cardValue = clvFoto.GetValue(i)
            nameToString = Data(3)
            nameToString = nameToString.Replace($"${barCodeData}_"$, "")
            
            Dim splitele() As String
            splitele = Regex.Split("_", cardValue.filename)
            
            If splitele(1) == nameToString Then 'if the image stored in the element matches the one sent via ftp
                Dim p As B4XView = clvFoto.GetPanel(i) 'clv panel
                Dim p2 As B4XView = p.GetView(0) 'mypanel (pnlFoto)
                Dim p3 As B4XView = p2.GetView(3) 'another my panel
                Dim p4 As B4XView = p3.GetView(0) 'another my panel2
            
                p3.Visible = True
                Dim c As CircularProgressBar = p4.GetView(0).Tag 'this View IS a CircularProgressbar
                
                c.Value = Data(0) 'HERE CRASHES'
                Exit
            End If
        Next
    Else
        lastCrcReference.Value = Data(0)
    End If
End Sub

This code generate this error:
java.lang.RuntimeException: Field: ba not found in: anywheresoftware.b4a.BALayout

I saw this post in the forum, But if I use p4.GetView(0).Tag I got this error
java.lang.RuntimeException: Field: ba not found in: java.lang.String

Thank you in advance
 

Mahares

Expert
Licensed User
Longtime User
This code generate this error:
java.lang.RuntimeException: Field: ba not found in: anywheresoftware.b4a.BALayout
Sometimes, the answer lies in the way your views tree looks in the Designer, The hierarchy and the order of the views is important. Maybe you are adding an extra panel in your code that should not be there. Stevel05, the powerhouse, alluded to something like this in post #11 of this thread.
Sometimes, posting the layout tree for people to see can help.
 
Upvote 0

Mike1970

Well-Known Member
Licensed User
Longtime User
Sometimes, the answer lies in the way your views tree looks in the Designer, The hierarchy and the order of the views is important. Maybe you are adding an extra panel in your code that should not be there. Stevel05, the powerhouse, alluded to something like this in post #11 of this thread.
Sometimes, posting the layout tree for people to see can help.

The hierarchy it's correct i'm sure, i print the tags to know what view i was selecting.
However
ftp2.PNG


I think is something related to the post i linked.. something related to the .Tag
Now i'm taking a look at this post, i finally found. But i've to understand well
 
Upvote 0

Mike1970

Well-Known Member
Licensed User
Longtime User
FOUND THE SOLUTION

The CirularProgressBar that Erel published, the following lines are missing in the DesignerCreateView Sub

B4X:
Tag = mBase.Tag '<-- store the designer set tag value
mBase.Tag = Me '<-- set the class reference discussed above

Then i wrote "CircularProgressBar" in the designer, in the Tag property (i don't know if this is necessary) and now it works :D
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
The CirularProgressBar that Erel published, the following lines are missing in the DesignerCreateView Sub
That is not bad for someone born in 1970. Mike, I think Erel created the newer AnotherProgressBar as part of the XUI Views library. If you check out the code in the class module 'AnotherProgressBar.bas. in the b4xlib, you will see that he accounts for the code that you said it was missing from the older circularProgressBar class that you are using. So, I am pretty sure if you used the one in the XUI Views lib, you would not have had the issue you had.
 
Upvote 0
Top