I have a list item which contains a CheckBox, and I want to be able to click on the CheckBox and on the list item itself. Unfortunately, there seems to be some sort of conflict between the two, as I can only click on the item when I comment out the CheckBox. It seems like I recall there was a way to fix this, but I can't find it at the moment. Thanks
EDIT: This is with a ListFragment, so there's no need to call setOnItemClickListener.
OK, here's the XML for the list item. The problem is the CheckBox, but I figured might as well copy everything.
<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>
You need to add this to your custom adapter xml file android:descendantFocusability="blocksDescendants"
insert this into the root element of the item row xml file
android:descendantFocusability="blocksDescendants"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With