2
最初に複数のRadioButtonをあらかじめ選択しておくと、Android APIレベル24(エミュレータ)で複数の選択ができるようです。私はこれがバグかどうかを知りたいだけですか?ここでAndroid RadiGroupで複数の選択が可能
は、レイアウトファイルです:
<?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>
アプリは、次のように起動します:
そして、私はジャズをクリックした場合、それはこのようになった:
おそらくバグではなく、XMLで2つをチェックしたが、単一選択肢を設定しなかったので説明します。そのため、ユーザーが選択肢を1つだけ選択してラジオグループの単一選択をしたい場合は、 –
'android:id'の値を' RadioButton'ウィジェットに割り当ててみてください。 [この問題](https://issuetracker.google.com/issues/36910867)を参照してください。 – CommonsWare
@CommonsWare、ありがとう、idを割り当てることはトリックを行い、最後にチェックされたものがUIでチェックされます。 Btw私はあなたの本を勉強していた:) –