Naseeb Sheoran
Naseeb Sheoran

Reputation: 473

radio button not clickable

I have made an application with four radio buttons.The problem is that the last radio button is unclickable initially untill you click some other button.After clicking some other radio button,the last radio button becomes clickable.plz tell me how to solve this problem.Thanks in advance.

private void uncheckAllOptions()
    {
        myOption1.setChecked(true);
        myOption2.setChecked(true);
        myOption3.setChecked(true);
        myOption4.setChecked(true);

        myOption1.setChecked(false);
        myOption2.setChecked(false);
        myOption3.setChecked(false);
        myOption4.setChecked(false);

}

I am using this code to save the state of the radio buttons but the last radio button always remains unclickable untill and unless one of the radio button among the first 3 is clicked

Upvotes: 2

Views: 6071

Answers (2)

Chintan Raghwani
Chintan Raghwani

Reputation: 3370

First of all put prop clickable=false in RadioButton-4 in XMl:

then suppose you want to make if clickable RadioButton-4 after clicking the FIRST RadioButton, then set RB-4 clickable=True in listener.

See following:

rb1.setOnCheckedChangeListener(new OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if(isChecked)
                    rb4.setClickable(true);
            }
        });

Upvotes: 0

Samir Mangroliya
Samir Mangroliya

Reputation: 40406

Use clearCheck() function of RadioButtonGroup to clear all RadioButtons.

Using myOption4.setChecked(false); can't checked next time until you check another RadioButton.

Like, radioButtonGroup.clearCheck();

Upvotes: 5

Related Questions