我无法从列表视图项中的复选框中删除焦点。每当我单击列表项时,复选框都会获得焦点。
我在Android 4.0.4 Samsung GT-P7500上遇到此问题。较新的版本没有这个问题。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:id="@+id/list_item_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/medium_padding"
android:descendantFocusability="blocksDescendants">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:id="@+id/category_checkbox"
android:focusable="false"
android:duplicateParentState="false"
android:focusableInTouchMode="false" />
正如您所看到的,我尝试了堆栈答案推荐的所有可用参数:
对于父母:
android:descendantFocusability="blocksDescendants"
复选框:
android:focusable="false"
android:duplicateParentState="false"
android:focusableInTouchMode="false"