Я динамически сгенерировал ListView, который состоит из переключателей в качестве элементов списка.
Можно ли использовать функциональность радиогруппы в этом списке или для этих переключателей.
Я имею в виду, я бы хотел, чтобы, если пользователь выберет переключатель, выбранный ранее переключатель будет отменен.
Это мое решение на данный момент, которое мне не очень нравится. Я просто сохраняю выбранный переключатель, и, если будет выбран другой, снимаю выделение с сохраненного.
Спасибо за ваши предложения или ссылки.
Вот мой макет:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/bg_tile"
android:padding="10dp">
<TextView
android:id="@+id/text_station_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:text="TEST"
android:textColor="@color/black"
android:background="@color/transparent_white"/>
<ListView
android:id="@+id/list_lines"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
item.xml:
<?xml version="1.0" encoding="utf-8"?>
<RadioButton xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rb_lineId"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="@color/black"
android:paddingLeft="50dp"
android:background="@drawable/selector_custombutton"/>
Но я также пробовали с этим:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/bg_tile"
android:padding="10dp">
<TextView
android:id="@+id/text_station_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:text="TEST"
android:textColor="@color/black"
android:background="@color/transparent_white"/>
<RadioGroup
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ListView
android:id="@+id/list_lines"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</RadioGroup>
</LinearLayout>