CheckBox
, a radio button cannot be unchecked by the user once checked.
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.
radioSex
,
radiomale
and radiofemale
and
btnDisplay
.
Selecting Female & pushing DISPLAY ⇒ |
|
|
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width = "match_parent" android:layout_height = "match_parent" android:orientation = "vertical" android:gravity = "center"> <RadioGroup android:id = "@+id/radioSex" android:layout_width = "wrap_content" android:layout_height = "wrap_content" > <RadioButton android:id = "@+id/radioMale" android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:text = "@string/radio_male" android:checked = "true" /> <RadioButton android:id = "@+id/radioFemale" android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:text = "@string/radio_female" /> </RadioGroup> <Button android:id = "@+id/btnDisplay" android:layout_below = "@+id/radioSex" android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:text = "@string/btn_display" /> </LinearLayout> |