B4J Question [ABMaterial] Event to detect change in ABMRadioGroup

Anser

Well-Known Member
Licensed User
Longtime User
Hi,

I use the below given code to use a ABMRadioGroup in the page
B4X:
Dim rbgroup As ABMRadioGroup
rbgroup.Initialize( page, "rbgroup", "radio")
rbgroup.AddRadioButton("Male", True)
rbgroup.AddRadioButton("Female", True)
rbgroup.SetActive(0)
rbgroup.Title = "Sex"

page.Cell(1,1).AddComponent(rbgroup)

Now my question is, which is the right event to detect whenever user changes/clicks the ABMRadioGroup ?

I would like to call a sub whenever the user changes the value in the ABMRadioGroup

Any help will be appreciated
 
Last edited:

Anser

Well-Known Member
Licensed User
Longtime User
Hi,

The below given code is working fine, but not sure whether this is the right way to get the value of the clicked item whenever the user changes the value in the radio group

I could not find any property of ABMRadioGroup to get the text of the Active Item, hence I used the below given method
B4X:
Sub rbgroup_Clicked(Target As String)
    Log(Target & " clicked")
    Dim cClickedOn As String
    Dim rbgroup As ABMRadioGroup = page.Component("rbgroup")
    If rbgroup.GetActive() = 0 Then
        cClickedOn = "Male"
    Else
        cClickedOn = "Female"
    End If
 
    myToastId = myToastId + 1
    page.ShowToast("toast" & myToastId, "toastgreen", "Clicked "&cClickedOn, 5000, False)
    page.Refresh
End Sub
 
Last edited:
Upvote 0
Top