I am doing an app to conduct simple quiz.I have given the answers are multiple choice using RadioGroup
. So on loading each question how can I set RadioGroup
unchecked by default ?
Asked
Active
Viewed 1.0k times
6

Malachi
- 33,142
- 18
- 63
- 96

Mohammed mansoor
- 743
- 3
- 11
- 18
3 Answers
14
Just set the checked
Property in your XML for every RadioButton
to false:
android:checked="false"
That should solve the issue.

Obl Tobl
- 5,604
- 8
- 41
- 65
6
Have you looked on the android developer guide?
http://developer.android.com/reference/android/widget/RadioGroup.html
Intially, all of the radio buttons are unchecked.
Although you can do this in code with the clearCheck()
method
Clears the selection. When the selection is cleared, no radio button in this group is selected and getCheckedRadioButtonId() returns null.
Perhaps your problem might be a different from my understanding. Perhaps explain more about how you are loading questions and so forth.

Malachi
- 33,142
- 18
- 63
- 96
3
Try
RadioGroup.check(0)
0 is an id which will nevere be generated by adt
upd: from source of RadioGroup
public class RadioGroup extends LinearLayout {
// holds the checked id; the selection is empty by default
private int mCheckedId = -1;
...

Korniltsev Anatoly
- 3,676
- 2
- 26
- 37