I would like to have radio buttons in one radiogroup divided into 2 columns and several rows.
So far, I have been able to divide them by putting LinearLayouts inside the radiogroup. The problem is that they are not exclusive when I click on them (I can check all of them at the same time). Is there a way to make them exclusive (besides a programmatic way)?
To make a horizontal radio button set, add the data-type="horizontal" to the fieldset . The framework will float the labels so they sit side-by-side on a line, hide the radio button icons and only round the left and right edges of the group.
Yes, there is a way. Drag a radio list widget to your screen, go to the Properties tab and select 'Orientation' -> Horizontal.
Vertical positioning of radio buttons is safer. Radio buttons are tiny in nature, and, thus, according to Fitts' law, they can be hard to click or tap.
here you go. Use getCheckedRadioButtonId() method on your RadioGroup to find out. It returns -1 when no RadioButton in the group is selected.
I came to this page with a slightly different question. I want to keep all my radio buttons horizontal. May this this will be helpful to someone. Setting the orientation will take care of placing all the radio buttons in a single row.
<RadioGroup
android:id="@+id/commuteby"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_below="@+id/line0" >
Note: if the components cross the screen then also it will place the components in same row. So some of your columns may be hidden in small screen phones. But you can create another layout file for small screens.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With