【发布时间】:2012-02-14 22:31:34
【问题描述】:
我有一个ListView,它为每一行膨胀一个包含CheckBox 和更多TextViews 的xml,这些RelativeLayout 中。
问题是我不知道如何将 onClick 事件从复选框传递到后排。
我想实现这种行为:用户按下复选框并按下整个列表行。如果我为每一行充气android.R.layout.simple_list_item_multiple_choice,我就会看到这种行为,但如果没有这个 android 特定的布局,我无法弄清楚如何做到这一点。
谁能给我一个想法或方向?
下面是代码:
列表视图:
<ListView
android:id="@+id/include_sent_list_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/white"
android:cacheColorHint="@color/white"
android:layout_alignParentTop="true"/>
以及为每一行膨胀的xml:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<CheckBox
android:id="@+id/checked_radio_button"
android:layout_width="50dp"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:focusable="false"
/>
<TextView
android:id="@+id/account_number_text"
android:layout_width="100dp"
android:layout_height="fill_parent"
style="@style/config_simple_small_text_view_style"
android:paddingTop="15dp"
android:layout_toRightOf="@id/checked_radio_button"
/>
<TextView
android:id="@+id/account_name_text"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
style="@style/config_simple_small_text_view_style"
android:paddingTop="15dp"
android:layout_toRightOf="@id/account_number_text"/>
</RelativeLayout>
【问题讨论】: