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 hig开发者_运维百科hlighted. 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!
Instead of setting individual RadioButton.setSelected(false), Use RadioGroup.clearCheck(). This worked for me :-)
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.
精彩评论