RadioGroup with More Than Just RadioButtons
Description
You can have non-RadioButton controls inside a radio group.
Example
The following RadioGroup
adds a TextView
after the last radio button.
Also note that the first radio
button (anotherRadBtn
) lies outside the radio group.
// www . j a v a 2 s . c o m
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<RadioButton
android:id="@+id/anotherRadBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Outside" />
<RadioGroup
android:id="@+id/radGrp"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RadioButton
android:id="@+id/chRBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Chicken" />
<RadioButton
android:id="@+id/fishRBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Fish" />
<RadioButton
android:id="@+id/stkRBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Steak" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="My Favorite" />
</RadioGroup>
</LinearLayout>
Note
The radio group can only enforce single-selection on the radio buttons in its own container.