Android API Level 24 (emulator) seems to allow multiple selection if I pre-select multiple RadioButton initially. I just want to know if this is a bug or not?
Here is the layout file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<RadioGroup
android:id="@+id/radioGroup"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/metal"
android:checked="true"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/classical"
android:checked="true"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/jazz"/>
</RadioGroup>
</LinearLayout>
The app launches like this:

And if I click on Jazz, it becomes like this:

Your layout lacks android:id values for the RadioButton widgets. That can work, if you're not starting with any of them pre-checked in the layout resource. If you are going to use android:checked in the layout resource, you need to assign widget IDs to the RadioButton widgets. This is a long-standing issue that is unlikely to change, so "it's just one of those things" that we have to deal with in Android app development.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With