我在 RadioGroup 中有一个 RadioButton,
当我设置按钮的初始状态时出现问题
机器人:检查=“真”
因为如果我按下单选按钮“F”,单选按钮“M”不会取消选中......
我能怎么做?怎么了?
这是代码:
<RadioGroup
android:id="@+id/registrazione_utente_sesso"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="M"
android:textColor="#ff7415"
android:textSize="18sp" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="13.33dp"
android:text="F"
android:textColor="#ff7415"
android:textSize="18sp" />
</RadioGroup>
screen:
初始状态(正确):
https://i.stack.imgur.com/bP4Zb.png https://i.stack.imgur.com/bP4Zb.png
当我按下单选按钮“F”(错误)时的最终状态:
https://i.stack.imgur.com/Jlsh2.png https://i.stack.imgur.com/Jlsh2.png
thanks
使用 android:id 为单选按钮分配一个唯一的 id,然后设置 RadioGroup 的 android:checkedButton 属性,如下所示:
<RadioGroup
android:id="@+id/registrazione_utente_sesso"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:checkedButton="@+id/radiobutton_m" >
<RadioButton
android:id="@+id/radiobutton_m"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="M"
android:textColor="#ff7415"
android:textSize="18sp" />
<RadioButton
android:id="@+id/radiobutton_f"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="13.33dp"
android:text="F"
android:textColor="#ff7415"
android:textSize="18sp" />
</RadioGroup>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)