CheckBox focusable="false" issue


#1

Hi there. On page 189, you mention setting the android:focusable attribute of the CheckBox to false so that the CheckBox will not intercept the touch. This does not work (for me, anyway) in isolation: you have to set android:clickable=“false” as well. Once I add that, it begins to work. I found the solution on Stack Overflow: stackoverflow.com/a/3134086/339671


#2

I didn’t find this problem. Did you have the enabled attribute set to false as well?

<CheckBox android:id="@+id/crime_list_item_solvedCheckBox" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:enabled="false" android:focusable="false" android:gravity="center" android:padding="4dp" />


#3

When I implemented this code as indicated in the book, clicking on a list item would send the message to the log as it should, EXCEPT when you click directly on the checkbox. Then no message was sent to the log. By adding android:clickable-“false”, it now logs a message regardless of where you click.


#4

Yes I did. Not sure what was going on.


#5

I had the same issue, and the solution given by glenng fixed it. Thanks!


#6

I had folks run into this just the other week for the first time. Surprised it took us so long - but yes, if you include clickable=false, then the checkbox will not intercept click events. You must also have focusable=false to enable the ListView click handling, though.