I am trying to build RadioGroup in Android with one RadioButton checked by default. I'm wondering if this is possible to do through XML, rather than programmatically.
The following code snippet doesn't seem to work as I'm getting an error:
error: Error: No resource found that matches the given name (at 'checkedButton' with value '@id/rdb_positive')
The code is:
<RadioGroup
style="@style/FormInputField"
android:orientation="vertical"
android:checkedButton="@id/rdb_positive"> <!-- Error on this line -->
<RadioButton
android:id="@+id/rdb_positive"
android:text="@string/answer_positive" />
<RadioButton
android:id="@+id/rdb_negative"
android:text="@string/answer_negative" />
</RadioGroup>
It does make sense in a way, as the id of the RadioButton is defined after the attribute in the RadioGroup is set, but then I wonder why there is such attribute available.