Android Question GetAllViewsRecursive with b4xView how to?

Gianni Sassanelli

Active Member
Licensed User
Longtime User
hi
i have a panel with 2 views EditText1 (tag=v1) and B4XFloatTextField1 (Tag= v2)
How to I get a B4XFloatTextField1 from GetAllViewsRecursive of a panel ?
By code do somethings as following code
thank's


B4X:
Dim pn As Panel
For Each v As B4XView In pnItem.GetAllViewsRecursive
Select NULL2EMPTYSTR(v.Tag )    
        Case "v1"
               v.as(EditText).Text ="testo 1"
        Case "v2"  ' never entry in this point
               v.Text ="testo 2"
End Select
next 

Sub NULL2EMPTYSTR(xVal As String) As String 
    Dim sf As StringFunctions
    If xVal = Null  Or sf.IsEmpty(xVal) Or xVal = "null"   Then
        Return ""
    Else
        Return xVal
    End If
End Sub

1627831444130.png
 

Mahares

Expert
Licensed User
Longtime User
How to I get a B4XFloatTextField1 from GetAllViewsRecursive of a panel ?
This should give you an idea how to proceed:.
B4X:
For Each v As B4XView In pnItem.GetAllViewsRecursive
        If v.Tag Is B4XFloatTextField Then
            Dim bft  As B4XFloatTextField  = v.Tag
            If "v2" = bft.Tag Then    'v2 is the tag in the designer tag property for the B4XFloatTextField
                    bft.Text="GIanni"
                    'do something
            End If
        else if "v1"= v.Tag Then 
            v.Text= "Italia"     'v1 is the tag in the designer tag property for the edittext1
            'do something else
        End If
    Next
 
Upvote 0
Top