Android RadioButton
RadioButton:
RadioButton is a User interface detail that permits the user to select one alternative from a set of at the same time distinct alternatives.
It is regularly utilized in groups in which only one alternative can be selected at a time. When one RadioButton in a set is selected, any previously decided on RadioButton inside the equal institution is automatically deselected.
Example:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".RadioButtonExample"
android:orientation="vertical"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="Choice to eat"
android:textSize="26sp"
android:textColor="@color/colorAccent"
/>
<RadioGroup
android:id="@+id/rgroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="50dp">
<RadioButton
android:id="@+id/rbutton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pizza"
android:textSize="16sp"
android:textColor="@color/colorPrimary"/>
<RadioButton
android:id="@+id/rbutton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Berger"
android:textSize="16sp"
android:textColor="@color/colorPrimary"/>
</RadioGroup>
</LinearLayout>
Output