RadioGroup.check(R.id.***), 当使用RadioGroup.check来设置默认选中时, 会出现二个问题:
一. OnCheckedChangeListener执行了二次
二.Caused by: java.lang.IllegalStateException: Fragment already added: Fragment
最终解决方案:
替代check方案:
用(RadioButton) findViewById(R.id.**).setChecked(true); 来设置默认选中即可.
本文解决使用RadioGroup.check设置默认选中时出现的两个问题:OnCheckedChangeListener执行了两次和Fragment已被添加错误。通过替代check方案,即使用(RadioButton)findViewById()并设置checked属性,实现正确设置默认选中。
1171

被折叠的 条评论
为什么被折叠?



