我有一個列表視圖動態填充CheckedTextViews。列表視圖被設置爲多選模式。我使用OnItemClickListener來響應我的列表視圖上的點擊。此外,我用CheckedTextView的佈局製作了一個XML文件(實際上它只是一個標準的android.R.layout.simple_list_item_multiple_choice的副本)。所以在這種情況下,所有工作都很好:當我點擊列表視圖中的某個項目時,相應的checkedtextview就會被檢查。但是當我嘗試使用以下佈局時,checkedtextview不響應點擊,仍然未選中。CheckedTextView沒有響應點擊
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ll"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="vertical"
android:padding="5px">
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:gravity="center_vertical"
android:drawableLeft="@drawable/checkbox_selector"
android:paddingLeft="6dip"
android:paddingRight="6dip"
android:background="#00ffffff"
android:textSize="15sp"
android:singleLine="true"/>
</LinearLayout>
我想這是因爲CheckedTextViews投入的LinearLayout,他們不從列表視圖的列表項接收click事件。