I can suggest. (but I still rather new to the CustomListView object model. There is likely a better way, but I assume that in your code that "adds" the button to each row you have something like this:
Dim p As B4XView = xui.CreatePanel("")
p.SetLayoutAnimated(0,0,0,100%x, 35dip)
p.LoadLayout("GridRow")
Label1.Text = Crsr.GetString("ID")
Label2.Text = Crsr.GetString("HotelName")
Label3.Text = Crsr.GetString("City")
Label4.Text = Crsr.GetString("FirstName")
RadioButton1.Checked = False
RadioButton1.Tag = Crsr.GetString("ID")
ViewData.Tag = Crsr.GetString("ID")
Return p
Now (even from designer), add a event for the radio button.
And, that code, you get this
Sub RadioButton1_CheckedChange(Checked As Boolean)
Dim r As RadioButton = Sender
Dim rRadioFromRow As RadioButton
' Log(r.Tag) this gives the current row id.
Dim i As Int
For i = 0 To CustomListView1.Size - 1
rRadioFromRow = CustomListView1.GetPanel(i).GetView(5)
If rRadioFromRow.Tag <> r.Tag Then
rRadioFromRow.Checked = False
End If
Next
Now, in above I had to "guess" which index the radio button is in the GetPanel. My spider sense tells me:
There is likely a better way to loop over each row.
There is likely a better way to get/grab/pull out the rRadioFromRow from the GetView.
However, the basic idea for above should work. I would hope the list is not too long.
And if anyone reading this?
Perhaps a for/each collection is available here? (I'm new to this).
So I not sure if above is the preferred way to loop over the custom list view.
However, while some kluge is in above? In theory the above idea is a means to do this. In above, for the tag setting I had a PK id from a data table, but anything from each row that can identify the separate row will work. (you could even use a loop counter in the panel add part).
I just don't know if a better means/way exists to figure out what index the radio button is in that "list".
So the 5 is a guess on my part - but it does work for me. You just have to figure out the index of the RadioButton in that single panel that you load for each row of the CustomListView.
Regards,
Albert D. Kallal
Edmonton, Alberta, Canada