Radio buttons are normally used together in a RadioGroup. When several radio buttons live inside a radio group, checking one radio button unchecks all the others.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<RadioGroup
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:checkedButton="@+id/option1"
android:id="@+id/radiogrooup">
<RadioButton
android:text="Option 1"
android:id="@+id/option1"/>
<RadioButton
android:text="Option 2"
android:id="@+id/option2"/>
<RadioButton
android:text="Option 3"
android:id="@+id/option3"/>
<RadioButton
android:text="Option 4"
android:id="@+id/option4"/>
</RadioGroup>
</LinearLayout>
0 Response to "RadioButton and RadioGroup"
Posting Komentar