B4J Question B4XRadioButton Example with Horizontal Buttons

B4XDev

Member
Licensed User
I'm trying to use B4XRadioButton, but I'm not sure the best way to set them up. Do I place one control and add buttons programmatically (like a split pane)? Do I place multiple controls, one for each button?

I can't find an example using the radio buttons laid out horizontally. Can anybody point me in the right direction or post a small example?

(The XUI Views example doesn't utilize B4XRadioButton. Maybe it could be added at some point, with an example of a row of horizontal radio buttons and an example of a column of vertical radio buttons.)
 

stevel05

Expert
Licensed User
Longtime User
I'm trying to use B4XRadioButton, but I'm not sure the best way to set them up. Do I place one control and add buttons programmatically (like a split pane)? Do I place multiple controls, one for each button?
I am not sure I understand the question.

The B4xRadioButton behaves the same as the standard radiobutton. A group is automatically created within the parent pane, so that only one can be selected at a time.
As with the standard radiobutton, there is not an option to have a horizontal B4xRadiobutton, you just set them next to each other.

If you want labels in a different position for the horizontal row (or any other) it is simple enough to remove the text from the B4xradiobutton and create a new label positioned where you want it. You can also capture the click on the label and select the correct B4xRadiobutton dependant on the text or tag of the label so it behaves the same as the text in the B4xRadiobutton.

See the attached example.
 

Attachments

  • rbtest.zip
    3.1 KB · Views: 180
Last edited:
Upvote 0

B4XDev

Member
Licensed User
The B4xRadioButton behaves the same as the standard radiobutton. A group is automatically created within the parent pane, so that only one can be selected at a time.

I had no idea I had to put them inside a pane. It doesn't seem to be stated anywhere. Where would someone find that information (other than, now, this thread)? Is there documentation specific to a B4XRadioButton that I missed?
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
You only need to add them to a Pane if you want more than one group, although it is probably cleaner to do so if it fits the layout. It is mentioned in the RadioButton documentation (although it's the Android documentation).

And this Wish, which was implemented

I don't think there is view specific documentation relating to the XUI Views
 
Upvote 0
Top