B4J Question Pane and Number of views

oldeast

Active Member
Licensed User
Longtime User
I used panel.numberofviews in B4A but its not available in B4J, could any please suggest a workaround.

I want to iterate the 5 radio buttons in a panel to set one as checked.
Code snippet attached.
Erel, so enjoying using B4J now,thanks very much.
 

Attachments

  • numberofviews.txt
    298 bytes · Views: 164

Roycefer

Well-Known Member
Licensed User
Longtime User
This returns a List of ALL RadioButtons that are a descendant of the Pane passed as a parameter. If you have Pane2 as a child of Pane1 and Pane2 also has RadioButtons, then the returned List will have Pane2's RadioButtons as well. You can store info in a RadioButton's Tag about its parent Pane and modify the sub to differentiate on that basis if you want.
B4X:
Sub DescendantRadioButtons(Pain As Pane) As List
    Dim res As List
    res.Initialize
    For Each n As Node In Pain.GetAllViewsRecursive
        If n Is RadioButton Then res.Add(n)
    Next
    Return res
End Sub

Beware, untested.
 
Upvote 0

oldeast

Active Member
Licensed User
Longtime User
Thank you.
My code:
Dim rb As RadioButton
For Each n As Node In paneHist
If n Is RadioButton Then
rb=n
If (rb.Tag) = His Then
rb.Selected=True
Else
rb.selected=False
End If
End If
Next
 
Upvote 0
Top