Ryan
Ryan

Reputation: 6866

Radio Buttons not highlighting as though they are selected

I'm working on an android activity with a RadioGroup containing 10 RadioButtons. For some reason or another sometimes, only sometimes, when you select a RadioButton in the RadioGroup it doesn't highlight as if it's selected but through some tests I've determined that it really IS selected even though it isn't highlighted. Another odd thing that occurs is that when you select any other RadioButton in the RadioGroup and then try selecting your original Radio Button (the one that wouldn't highlight as though it were selected) it does highlight and functions as normal.

Any idea why this is happening or how to fix it? Thanks!

Upvotes: 0

Views: 1347

Answers (2)

Sash_KP
Sash_KP

Reputation: 5591

RadioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener()
{
            public void onCheckedChanged(RadioGroup grp,int checkedId){
    int selected = RadioGroup.getCheckedRadioButtonId();
    RadioButton b = (RadioButton) findViewById(selected);
}
});

Use this concept for extracting the correct value of checked radiobutton.

Upvotes: 0

Ragunath Jawahar
Ragunath Jawahar

Reputation: 19733

Instead of setting individual RadioButton.setSelected(false), Use RadioGroup.clearCheck(). This worked for me :-)

Upvotes: 1

Related Questions