I want to set my RadioGroupView to not clickable so that the user can't click on the buttons. I tried mRadioGroup.isActivated = false
but it has no effect on my RadioGroup View. Have somebody a hint for me?

- 5,523
- 4
- 28
- 57
5 Answers
Disable for each button
for (int i = 0; i < mRadioGroup.getChildCount(); i++) {
mRadioGroup.getChildAt(i).setEnabled(false);
}

- 3,041
- 1
- 16
- 32
Have you tried set RadioGroupView clickable = false?
If it's not working, you can put a View overlay whole RadioGroup layout and set this view clickable = true.

- 7,846
- 14
- 53
- 103

- 53
- 5
In order to disable the radio buttons inside radio group you need to manually disable each button with the help of radioButton1.setEnabled(false)
method.
However better way is to loop through the radio buttons inside mRadioGroup with the help of getChildAt()
method
for (int i = 0; i < mRadioGroup.getChildCount(); i++){
mRadioGroup.getChildAt(i).setEnabled(false);
}

- 135
- 1
- 4
- 8
Building on Prithvi Bhola's answer you can use a Kotlin extension function that you simply add to your Activity
:
fun RadioGroup.setChildrenEnabled(enabled: Boolean) {
for (i in 0 until childCount) {
getChildAt(i).isEnabled = enabled
}
}
Then, whenever you need to you can simply disable or enable all RadioButtons
in the RadioGroup
:
mRadioGroup.setChildrenEnabled(false)

- 1,581
- 12
- 19
RadioGroup cannot be disabled directly, we have to loop through the radio button and set it enabled as false.
Try this:
for(int i = 0; i < rg.getChildCount(); i++){
((RadioButton)rg.getChildAt(i)).setEnabled(false);
}
Hope this will help.

- 7,501
- 5
- 28
- 50