2015-12-22 2 views
3

У меня есть довольно простая группа переключателей, созданная с помощью AppCompatRadioButtons из библиотеки поддержки. Тем не менее, группа, похоже, не работает над версиями Lollipop. Я могу выбрать каждый вариант и не могу найти никаких указаний о том, почему он это делает.Радиогруппа для AppCompatRadioButtons не работает на Jelly Bean?

Я тестирую эмулятор под управлением 4.1. Как вы можете видеть ниже, я могу выбрать несколько вариантов.

enter image description here

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

    <android.support.v7.widget.AppCompatRadioButton 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:text="W"/> 

    <android.support.v7.widget.AppCompatRadioButton 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:text="Q"/> 

    <android.support.v7.widget.AppCompatRadioButton 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:text="B-Hum"/> 

    <android.support.v7.widget.AppCompatRadioButton 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:text="B-Sci"/> 

    <android.support.v7.widget.AppCompatRadioButton 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:text="B-Soc"/> 
</RadioGroup> 

Тестирование на леденец и Зефир получает необходимые результаты.

+0

Я испытал ту же самую компоновку в устройстве htc с версией jellybean. он работает нормально .. только один AppCompatRadioButton выбран сразу –

ответ

-1

Определите уникальный идентификатор для каждого AppCompatRadioButton. Например:

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

    <android.support.v7.widget.AppCompatRadioButton 
     android:id="@+id/radio_w" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:text="W"/> 

    <android.support.v7.widget.AppCompatRadioButton 
     android:id="@+id/radio_q" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:text="Q"/> 

    <android.support.v7.widget.AppCompatRadioButton 
     android:id="@+id/radio_bhum" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:text="B-Hum"/> 

    <android.support.v7.widget.AppCompatRadioButton 
     android:id="@+id/radio_bsci" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:text="B-Sci"/> 

    <android.support.v7.widget.AppCompatRadioButton 
     android:id="@+id/radio_bsoc" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:text="B-Soc"/> 

</RadioGroup> 
Смежные вопросы