I have read in an example that if you use more than one radio button you should use RadioGroup like this:
<RadioGroup
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RadioButton
android:id="@+id/radio_pirates"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="14dp"
android:layout_marginLeft="100dp"
android:onClick="onRadioButtonClicked"
android:text="@string/attendance"
android:textSize="8dp"
/>
<RadioButton
android:id="@+id/radio_pirates2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="14dp"
android:layout_marginLeft="100dp"
android:onClick="onRadioButtonClicked"
android:text="@string/attendance"
android:textSize="8dp"
/>
</RadioGroup>
If I have only one radio button, can I remove <RadioGroup> or that is wrong ?
From the doc
However, contrary to a CheckBox, a radio button
cannot be unchecked by the user once checked.
So, if you wish to give only one option button to select the user then use
CheckBoxorToggleButton