设置RadioGroup下所有radioButton均不可点击
正常地说一般要是使一个控件不可点击,不外乎使用以下几种方法
- setEnable
- setClickable
- setFocusable
但是对于RadioGroup而言以上均失效,想要达到使RadioGroup下所有Button均不可点击的状态,需要遍历这个group,针对单独一个button去设置就可以达到上述效果
public void disableRadioGroup(RadioGroup testRadioGroup) {
for (int i = 0; i < testRadioGroup.getChildCount(); i++) {
testRadioGroup.getChildAt(i).setEnabled(false);
}
}
public void enableRadioGroup(RadioGroup testRadioGroup) {
for (int i = 0; i < testRadioGroup.getChildCount(); i++) {
testRadioGroup.getChildAt(i).setEnabled(true);
}
}