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 ?
how can i set RadioGroup unchecked by default in android?
Asked Answered
Just set the checked
Property in your XML for every RadioButton
to false:
android:checked="false"
That should solve the issue.
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.
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;
...
© 2022 - 2024 — McMap. All rights reserved.