質問

I have a RadioGroup radioGroup with 2 RadioButton rb1 and rb2.

User checks 1 of them, say rb1, at some point of time. Now based on some condition, I want to clean the RadioGroup i.e.all it's children should be unchecked.

I'm doing so by rb1.setChecked(false); and rb2.setChecked(false);.

After this when I call radioGroup.getCheckedRadioButtonId();, I'm expecting -1 as return value, but what I get is the id of rb1, which I had checked earlier.

Am I doing something wrong?

Any help appreciated.

役に立ちましたか?

解決

You need to call radioGroup.clearCheck()

See the doc : http://developer.android.com/reference/android/widget/RadioGroup.html#clearCheck()

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top