(Android) RadioButton设置setCheck(true)无效

今天碰到个问题,RadioButton设置setCheck(true)无效,布局xml是RadioGroup里包含了几个RadioButton。

经验证,发现之前有个调用,把所有RadioButton都调用setChecked(false),这个会导致再次设置setCheched(true)无效。

解决:把所有RadioButton置为setChecked(false)的地方 改为 RadioGroup.clearCheck(),或者根本不需要调这个方法(如果进入时,每次都有默认的RadioButton被选中),直接调用某个RadioButton.setCheck(true)就行了。

猜你喜欢

转载自blog.csdn.net/geniushorse/article/details/83987590