RadioButton is a radio button
, so there is only one choice, but in the development, there will be a phenomenon that RadioButton can select more than one. Without adding the id attribute, there will be multiple selections in the simulator.
Correct writing:
<RadioGroup android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="15dp" android:orientation="horizontal" > <RadioButton android:id="@+id/rbMale" android:checked="true" android:text="男" /> <RadioButton android:id="@+id/rbFmale" android:text="女" /> </RadioGroup>
Wrong spelling:
<RadioGroup android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="15dp" android:orientation="horizontal" > <RadioButton android:checked="true" android:text="男" /> <RadioButton android:text="女" /> </RadioGroup>