How to disable a RadioGroup until checkbox is checked

The real trick is to loop through all children view (in this case: CheckBox) and call it’s setEnabled(boolean)

Something like this should do the trick:

//initialize the controls
final RadioGroup rg1 = (RadioGroup)findViewById(;
CheckBox ck1 = (CheckBox)findViewById(;

//set setOnCheckedChangeListener()
ck1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

    public void onCheckedChanged(CompoundButton checkBox, boolean checked) {
        //basically, since we will set enabled state to whatever state the checkbox is
        //therefore, we will only have to setEnabled(checked)
        for(int i = 0; i < rg1.getChildCount(); i++){

//set default to false
for(int i = 0; i < rg1.getChildCount(); i++){

Leave a Comment