我有一个具有以下布局的自定义 listView,我希望它的行为类似于普通的 SingleChoiceListView。虽然我为 Single_Choice_Mode 设置了列表视图,但是当我单击时,单选按钮没有被选中。我究竟做错了什么?单行的 xml 布局是:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:minHeight="?listPreferredItemHeightSmall"
android:orientation="horizontal"
android:clickable="true"
android:focusable="true"
android:paddingLeft="16dip"
android:paddingRight="12dip" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical"
android:orientation="vertical" >
<TextView
android:id="@android:id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:gravity="center_vertical|left"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="?textColorAlertDialogListItem" />
<TextView
android:id="@android:id/text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:gravity="center_vertical|left"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?textColorAlertDialogListItem" />
</LinearLayout>
<TextView
android:id="@+id/preco"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:ellipsize="marquee"
android:gravity="fill"
android:singleLine="true"
android:textStyle="bold"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@color/appgreen" />
<RadioButton
android:id="@+id/radio"
android:layout_width="35dip"
android:layout_height="wrap_content"
android:clickable="false"
android:focusable="false"
android:gravity="center_vertical"
android:paddingRight="12dip" />
</LinearLayout>