The phenomenon that RadioButton can be selected multiple times

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>

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326945244&siteId=291194637