1.onItemLongClick and Onitemclick event interception
When you need to get an entry for a ListView in both long press events (Onitemlongclick) and click events (Onitemclick), justreturn to True in the Onitemlongclick event trigger function.
2. Customizing the checkbox style
In the layout file, add a property to Android:button, say no more, directly on the code
<checkbox android:id= "@+id/xxx" android:layout_width= "wrap_content" android:layout_height= "wrap _content " android:layout_marginright=" 5DP " android:button=" @drawable/checkbox_selector " android: text= "xxx" />
Checkbox_selector.xml
<?xml version= "1.0" encoding= "Utf-8"? ><selector xmlns:android= "http://schemas.android.com/apk/res/ Android "> <item android:state_checked=" true " android:drawable=" @drawable/checkbox_selected_ Selector "/> <item android:state_checked=" false " android:drawable=" @drawable/checkbox_blank_ Selector "/></selector>
Checkbox_selected_selector.xml
<?xml version= "1.0" encoding= "Utf-8"? ><selector xmlns:android= "http://schemas.android.com/apk/res/ Android "> <item android:state_pressed=" true " android:drawable=" @drawable/checkbox_ya "/> <item android:state_pressed= "false" android:drawable= "@drawable/checkbox_yz"/></selector>
Checkbox_blank_selector.xml
<?xml version= "1.0" encoding= "Utf-8"? ><selector xmlns:android= "http://schemas.android.com/apk/res/ Android "> <item android:state_pressed=" true " android:drawable=" @drawable/checkbox_wa "/> <item android:state_pressed= "false" android:drawable= "@drawable/checkbox_wz"/></selector>
Focus issue with button or checkbox in Item 3.ListView
When customizing a ListView, each item has a button component or other component that can also be clicked (usually a button and a checkbox) on the other, since the focus is obtained by the button component, Then clicking on item is actually the equivalent of clicking on the button component.
Workaround: Add in the root layout of item
Android:descendantfocusability= "Blocksdescendants"
There is also a way to add a button component
Android:focusable= "false"