Radio Buttons: Layout File

RadioGroup class
This class is used to create a multiple-exclusion scope for a set of radio buttons. Checking one radio button that belongs to a radio group unchecks any previously checked radio button within the same group. Intially, all of the radio buttons are unchecked. While it is not possible to uncheck a particular radio button, the radio group can be cleared to remove the checked state. The selection is identified by the unique id of the radio button as defined in the XML layout file.

RadioButton class
A radio button is a two-states button that can be either checked or unchecked. When the radio button is unchecked, the user can press or click it to check it. However, contrary to a 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.
There are four IDs declared in this layout file:
Selecting
Female &

pushing
DISPLAY


MyApplication/app/src/main/res/layout/activity_main.xml
<?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>




      He who knows all the answers has not been asked all the questions.    
      ― Confucius