Android – why does radiogroup choose multiple RadioButtons

I added two RadioButtons under radiogroup and enabled the first one. When I selected the second one, it did not deselect the first one. Can you suggest me what the problem is

This is my XML:

<RadioGroup 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:orientation="horizontal">
        <RadioButton 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:checked="true"
            android:text="NO"/>
        <RadioButton 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="YES"/>
</RadioGroup>

resolvent:

Try this:

<RadioGroup 
        android:id="@+id/radioGrp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:orientation="horizontal">
        <RadioButton 
            android:id="@+id/radio1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:checked="true"
            android:text="NO"/>
        <RadioButton 
            android:id="@+id/radio2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="YES"/>
</RadioGroup>

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>