Android – Unable to Check Custom Item from ListView

My ListView contain a list of custom items. Each item contains a CheckBox and an associate TextView. I wanted to check/uncheck items from the ListView, but it didn’t let me.

—————————————————————

 According Matt C’s solution on SO, Android doesn’t allow selections on items that are focusable (namely CheckBox). The fix was quite simple =A=; just add the following line in the CheckBox attribute to disable focus:

android:focusable="false"

 

After adding the above line will make the item selectable EXCLUDING the checkbox. You either want to implement the checkbox with another action or can simply disable clickable for it to work with the ListView.

android:clickable="false" 

—————————————————————-

 So now i have something like this =3=:

<CheckBox
        android:id="@+id/checkBox1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:focusable="false"
        android:clickable="false"
/>

 

Source: http://stackoverflow.com/questions/1121192/android-custom-listview-unable-to-click-on-items

 

Advertisements