<RadioButton
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:enabled="true"
android:selectAllOnFocus="true" />
私はこのコードを使用しましたが、私のために働いていません。Android XMLを使用してラジオボタンをデフォルトで有効にする方法
<RadioButton
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:enabled="true"
android:selectAllOnFocus="true" />
私はこのコードを使用しましたが、私のために働いていません。Android XMLを使用してラジオボタンをデフォルトで有効にする方法
私はあなたが、初心者によって頻繁に起こる、有効にされたという意味を誤解していると思います。 android:enabled="true"
は、RadioButton
が使用可能であることを意味します。たとえば、有効になっていないRadioButton
は、ユーザーのクリックに反応しません。何が必要checked
です:
android:checked="true"
チェックアウトドキュメント:https://developer.android.com/guide/topics/ui/controls/radiobutton.html https://developer.android.com/reference/android/widget/RadioButton.html
それはですしてみてください!
<RadioButton
android:id="@+id/radioButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:checked="true"
android:text="RadioButton" />
変更:
android:enabled="true"
のために:
RadioButton b = (RadioButton) findViewById(R.id.option1);
b.setChecked(true);
私はこの意志を願っています:プログラムで
android:checked="true"
、あなたがチェック可能なインタフェースで定義されたsetCheckedメソッドを使用することができますお手伝いしましょう。
代わりの
android:enabled="true"
この
android:checked="true"
を使用します