B4J Code Snippet RadioGroup

Ola!

This creates a radiogroup from a list of options you specify side by side. One is able to set and also return the text of the selected item.

RadioGroup.gif


Creating the RadioGroup

B4X:
Dim lst As List
    lst.Initialize
    lst.Add("Male")
    lst.Add("Female")
    lst.Add("Other")
    lst.Add("Anele Mbanga")
    lst.Add("Loves B4X")
    'add the radio items as a list and select Other
    Dim pnl As Pane = TableViewSetRadioButton("rbx","Other","",lst)
    'MainForm.RootPane.AddNode(pnl,0,0,-1,-1)
    Pane1.AddNode(pnl,0,0,-1,-1)

Getting the Selected Option

B4X:
Sub Button1_Click
    Dim rbTxt As String = TableViewGetRadioButton(Pane1)
    Log("Button1_Click: " & rbTxt)
    fx.Msgbox(MainForm,rbTxt,"Radio Group ButtonClick")
End Sub

See attached source code for more.

Ta!
 

Attachments

  • RadioGroup.zip
    3.9 KB · Views: 265
Top