0

複数のラジオボタンを使用する場合は、次のように使用する必要があるという例を読みましたRadioGroup

<RadioGroup
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal">


       <RadioButton
           android:id="@+id/radio_pirates"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_marginTop="14dp"
           android:layout_marginLeft="100dp"
           android:onClick="onRadioButtonClicked"
           android:text="@string/attendance"
           android:textSize="8dp"

            />
   <RadioButton
           android:id="@+id/radio_pirates2"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_marginTop="14dp"
           android:layout_marginLeft="100dp"
           android:onClick="onRadioButtonClicked"
           android:text="@string/attendance"
           android:textSize="8dp"

            />
       </RadioGroup>

ラジオボタンが1つしかない場合、削除できます<RadioGroup>か、それとも間違っていますか?

4

2 に答える 2

2

ドキュメントから

ラジオ ボタンは、オンまたはオフにできる 2 つの状態のボタンです。ラジオ ボタンがオフの場合、ユーザーはそれを押すかクリックしてオンにできます。ただし、CheckBox とは異なり、ラジオ ボタンは、一度チェックするとユーザーがチェックを外すことはできません。

ただし、CheckBox とは異なり、ラジオ ボタンは、一度チェックするとユーザーがチェックを外すことはできません。

したがって、ユーザーを選択するためのオプション ボタンを 1 つだけ指定する場合は、CheckBoxまたはを使用します。ToggleButton

于 2012-10-18T08:17:53.280 に答える
1

はい、できます。
ただし、ラジオボタンが1つある場合は、一度チェックするとチェックを外すことができます。

Intially, all of the radio buttons are unchecked.While it is not possible to
uncheck a particular radio button, the radio group can be cleared to remove the 
checked state.

そのためCheck Box、ラジオボタンの代わりに使用することをお勧めします。

于 2012-10-18T08:17:39.567 に答える