Android Question locating specific views in xCustomScrollView

tkristensen

Member
Licensed User
Longtime User
I have a xCustomScrollview that contains 4 panels.

The first 3 each consist of 2 checkboxes
the last contains a checkbox, edittext and a radio button

What I am trying to do is when the radio button is pressed programmatically un check all of the check boxes and clear the edit text.

Each of the controls as a tag set to it's order.. so the first one has tags 1 and 2, 2nd 3 and 4 etc

at the end of this I need to determine how many of the checkboxes are checked and what the value of the edittext.text is.

any help appreciated.

Tom
 

Mahares

Expert
Licensed User
Longtime User
any help appreciated
Here is a solution based on your explanation as I understood it. Once you click the radio button, it will uncheck all checkboxes in that xClv item, records the edittext text and then clears it.
B4X:
Sub RadioButton1_CheckedChange(Checked As Boolean)
    Dim index As Int = CustomListView1.GetItemFromView(Sender)
    Dim panel As B4XView = CustomListView1.GetPanel(index)
 
Dim n As Int
    For Each x As B4XView In panel.GetAllViewsRecursive
        If x Is CheckBox Then
            Dim c As CheckBox = x
            If c.Checked Then
                n = n+1
            End If
            c.Checked=False
        else if x Is EditText Then
            Dim e As EditText =x
            Log(e.Text)
            e.Text= ""
        End If
    Next
    Log($"number of chkbx that where checked ${n}"$)
    panel.GetView(3).GetView(2).Checked= Not(panel.GetView(3).GetView(2).Checked)  'resets the radio button
    'radio button is in 4th panel and is the 3rd view in that panel
End Sub
See the screenshot attached for the views tree I envisioned:
When you are dealing with an item layout that has so many views and somewhat complex, you should always show your views tree and the layout file to get concrete help if you do not want people to guess.
 

Attachments

  • ItemsLayoutScreenshot.PNG
    ItemsLayoutScreenshot.PNG
    14.3 KB · Views: 214
Last edited:
Upvote 0
Top