Использование Switch лучше:

лько я понимаю, чтобы определить, «установлен ли флажок», и определить, установлен он или нет, можно использовать такой код:

cb=(CheckBox)findViewById(R.id.chkBox1);
        cb.setOnCheckedChangeListener(this);

public void onCheckedChanged(CompoundButton buttonView, 
    boolean isChecked) { 
        if (isChecked) { 
            cb.setText("This checkbox is: checked"); 
        } 
        else { 
            cb.setText("This checkbox is: unchecked"); 
        } 
    }

Тем не менее, я не могу выработать логику, как это сделать для радиогруппы.

Вот XML для моей RadioGroup:

<RadioGroup android:id="@+id/radioGroup1" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content">
    <RadioButton android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:id="@+id/radio1" android:checked="true" 
    android:text="RadioButton1">
    </RadioButton>
    <RadioButton android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:id="@+id/radio2" android:text="RadioButton2" android:checked="true">
    </RadioButton>
    <RadioButton android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:id="@+id/radio3" android:text="RadioButton3">
    </RadioButton>
</RadioGroup>

Вопрос: мне нужно настроить другого слушателя, или слушатель уже там "зарегистрирует" эту группу?

Кроме того, должен ли слушатель быть настроен на RadioGroup или RadioButton?

Ответы на вопрос(4)

Ваш ответ на вопрос