Android Question RadioButtons in Customlistview

AaronF88

Member
Licensed User
Longtime User
Good morning,

I'm struggling to work out how to get RadioButtons to work with CustomListViews. I presume its because that the RadioButtons are placed on different panels?

Any help would be appreciated!

B4X:
#Region Module Attributes
    #FullScreen: False
    #IncludeTitle: True
    #ApplicationLabel: CustomListView Example
    #VersionCode: 1
    #CanInstallToExternalStorage: False
#End Region

'Activity module
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    Dim clv1 As CustomListView
    Dim lv4 As CustomListView
    Dim mainrad(4) As RadioButton
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("1")
    lv4.Initialize(Me, "LV4")
    Activity.AddView(lv4.AsView ,0dip,0dip, 100%x, 100%y)
    lv4.Add(CreateListItem6("First", -1, 65dip, 1, "randomtext123"), 65dip, "1")
    lv4.Add(CreateListItem6("Second", -1, 65dip, 2, "randomtext123"), 65dip, "2")
    lv4.Add(CreateListItem6("Third", -1, 65dip, 3, "randomtext123"), 65dip, "3")

End Sub

Sub clv1_ItemClick (Index As Int, Value As Object)
    Activity.Title = Value
End Sub

Sub LV4_ItemClick(Index As Int, Value As Object)
    Log(Index & " = " & Value)
End Sub

Sub CreateListItem6(text As String, Width As Int, Height As Int, i As Int, btmtext As String) As Panel
Dim test1 As Panel
Dim Lblbtm, lbltop As Label

    test1.Initialize("test1")

    test1.Color = Colors.White
    lbltop.Initialize("")
    Lblbtm.Initialize("")
   
    lbltop.text=text
    Lblbtm.text = btmtext
    lbltop.TextSize = 18
    lbltop.TextColor = Colors.ARGB(255,0,0,0)
   
    Lblbtm.TextSize = 14
    Lblbtm.TextColor = Colors.ARGB(225,50,50,50)

    mainrad(i).Initialize("mainrad")
    mainrad(i).Tag = i

    test1.AddView(lbltop, 16dip, 4dip, 60%x, -1) 'view #0
    test1.AddView(Lblbtm, 16dip, 24dip, 60%x, -1) 'view #1
    test1.AddView(mainrad(i), 100%x-116dip, 0dip, 100dip, 50dip) 'view #2
    Return test1
   
End Sub
Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
 

Attachments

  • RadioBtnCLV.zip
    9.3 KB · Views: 213

klaus

Expert
Licensed User
Longtime User
You cannot do it.
RadioButtons work only if they are in a same container, Activity or Panel.
As each item in the CustomListView is a Panel the RadiobButtons on different items are independant !
Or you need to manage them yourself.
 
Upvote 0
Top