how can i set RadioGroup unchecked by default in android?
Asked Answered
R

3

6

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 ?

Renarenado answered 21/3, 2013 at 12:22 Comment(0)
W
14

Just set the checked Property in your XML for every RadioButton to false:

android:checked="false"

That should solve the issue.

Worn answered 21/3, 2013 at 12:26 Comment(0)
O
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.

Orbit answered 21/3, 2013 at 12:25 Comment(0)
K
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;
    ...
Kerley answered 21/3, 2013 at 12:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.