我有一个ListView
:单选按钮选择。
<ListView
android:id="@+id/my_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
的ListView
的每一行的布局是:
<? Xml version="1.0"encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ImageView
android:id="@+id/my_img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_algnParentLeft="true"
android:layout_centerVertical="true"
/>
<TextView
android:id="@+id/my_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/my_img"
android:textColor="@drawable/black" />
<RadioButton
android:id="@+id/my_radio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/my_value" />
</ RelativeLayout>
正如你看到的上面,对列表中的每一行,如何实现RadioButton
以下两个特点视为RadioButton
:
1.假设列表中有3项,如何使每行上的单选按钮在列表中执行单选? (默认情况下,我可以选择所有单选按钮)
2.如何拥有对单选按钮选择每个项目行区域点击,而不是只点击单选按钮进行选择?
也许帮助http://stackoverflow.com/questions/7329856/how-to-use-radiogroup-in-listview-custom-adapter – 2012-03-26 11:39:23