Just wanted to see if anyone knows if there's a radiogroup or radiobutton attribute or something else quick that will allow radio buttons to be unchecked when they're in checked mode. I'm looking to build functionality that works like a radio group (i.e. only one can be checked) but I also want them to be able to be all unchecked.
Maybe I don't get the question here, but this is something I wanted to do. I have a single activity that I use to classify many pictures. I am classifying using radio buttons. After the user checks one of the options he is allowed to switch with the next picture. I needed to clear the selection, when switching the picture, but decided not to create new activity.
So I initialize my radio group in the layout like that:
<RadioGroup
android:id="@+id/radio_selection"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<RadioButton
android:id="@+id/radio_true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:text="@string/true" />
<RadioButton
android:id="@+id/radio_false"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:text="@string/false" />
</RadioGroup>
This initializes my radio group and both RadioButton
are not selected initially. Afterwards when I change the picture I need to clear the selection (because user has not yet chosen for the new picture). I do like that:
RadioGroup radioGroup = (RadioGroup)findViewById(R.id.radio_selection);
radioGroup.clearCheck();
This is doing exactly what I need: making again none of the radio buttons being selected. I hope I understood the question and this will help somebody in the future.