設置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);
}
}