出现RadioButton可以多选的现象
RadioButton是一种单选按钮
故选择是只有一个的,但是在开发中却会出现RadioButton可以多选的现象,究其原因,发现只有在RadioButton中添加了id属性才可以实现单选的作用,如果没有添加id属性,就会在模拟器中出现可以多选的现象
正确的写法:
<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>
错误的写法:
<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> 相关推荐
韩伟佳 2020-10-09
wuleihenbang 2020-09-16
zzqLivecn 2020-07-09
chenjinlong 2020-06-10
yinbaoshiguang 2020-06-09
sgafdsg 2020-06-04
ustcrding 2020-06-03
chenjinlong 2020-06-03
AndroidGA 2020-06-01
安辉 2020-05-27
绿豆饼 2020-05-26
CNETNews 2020-05-26
xilove0 2020-05-12
绿豆饼 2020-05-12
ChainDestiny 2020-05-07
doomvsjing 2020-05-07
hqulyc 2020-05-05
lyccsu 2020-04-30