我有一个包含CheckBox的列表项,我希望能够单击CheckBox和列表项本身.不幸的是,两者之间似乎存在某种冲突,因为我只能在注释掉CheckBox时单击该项.我好像记得有办法解决这个问题,但目前我找不到它.谢谢
编辑:这是一个ListFragment,所以没有必要调用setOnItemClickListener.
好的,这是列表项的XML.问题是CheckBox,但我想也可以复制一切.
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/list_item_survey"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="@style/SimpleListItem">
<TextView
android:id="@+id/survey_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="@style/ListItemTitle" />
<TextView
android:id="@+id/survey_date"
android:layout_below="@id/survey_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/ListItemSubtitle" />
<TextView
android:id="@+id/survey_completed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@id/survey_title"
android:textColor="@color/accent_1"
android:text="@string/survey_completed"
style="@style/ListItemSubtitle" />
<CheckBox
android:id="@+id/survey_did_not_attend"
android:layout_below="@id/survey_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/survey_did_not_attend"
android:focusable="false"
style="@style/ListItemSubtitle" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
Sun*_*nil 28
你需要将它添加到自定义适配器xml文件android:descendantFocusability ="blocksDescendants"
sar*_*mar 23
将其插入到项行 xml文件的根元素中
android:descendantFocusability="blocksDescendants"
Run Code Online (Sandbox Code Playgroud)
这对我有用
<CheckBox
...
android:focusable="false"
android:clickable="false"
android:focusableInTouchMode="false" />
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
18169 次 |
| 最近记录: |