I\'m having an issue with RadioGroup\'s clearChecked(). I\'m displaying a multiple choice question to the user and after the user selects an answer I check the answer, give
I had similar problem. My solution:
in procedure:
public void onCheckedChanged(RadioGroup rGroup, int checkedId)
I check checkedId. It equals to -1 if you use clearCheck() else it equals to selected radiogroup child
I faced the same problem and i solved with other work-around.
rdbGroup.setOnCheckedChangeListener(null);
rdbGroup.clearCheck();
rdbGroup.setOnCheckedChangeListener(checkedChangeListener);
Hope this will help ツ
What I've discovered is that if an item is checked and you call clearCheck()
on the radio group it will call onCheckedChanged
twice. The first time with the id of the item that was checked and the second time with -1
/View.NO_ID
. IMHO, this is a bug and apparently it has been around since at least 1.6. See this google code bug report: http://code.google.com/p/android/issues/detail?id=4785
It seems to be that the only solution is to check the actual RadioButton.isChecked()
and test if it is true or false. This sort of defeats the purpose of the onCheckedChanged
returning the id of the item since you now have to either keep references to those buttons or call findViewById
every time.
I doubt they will fix this since changing it would probably break existing code in unexpected ways.