Android Question B4XPlusMinus casting

advansis

Active Member
Licensed User
Longtime User
Hi guys,
I have several B4XPlusMinus controls in my activity. I want to use a FOR..NEXT loop to populate the values. What I do is in the following code:
B4X:
For Each V As View In Activity.GetAllViewsRecursive
    If V Is B4XPlusMinus Then
        Dim PM As B4XPlusMinus=V
        PM.SetNumericRange(0,255,1)
    End If
Next

Unfortunally, the code, as is, doesn't work.
I know the error is in the 3rd line (Dim PM as ...), is there another way to cast the View as B4XPlusMinus?

Thanks in advance
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
The explanation for the correct answer above, is that the custom view instance is not a view by itself. It adds to the views tree a panel (V in this code).

XUI Views set the panel's tag property to the class instance:
B4X:
mBase.Tag = Me
This makes it easy to get the class instance from the views tree.

Note that there is another Tag property in these custom views that you can use if needed.
 
Upvote 0
Top