setOnItemClickListener() not working on custom ListView @ Android

I have Implemented a custom ListView by extending LinearLayout for every row. Every row has a small thumbnail, a text and a check box. The list view is deployed properly and I can scroll and fling through it without any problems.

But The ListView doesn't seem to respond to the setOnItemClickListener() at all, So I had to find a workaround by setting click listener in the getView() of the Text inside every row which is obviously creating problem when I am trying to reuse the adapter. Does anyone have a solution?


Solution 1:

Try this
For ListView,

final ListView list = (ListView) findViewById(R.id.list);
list.setItemsCanFocus(false);

Also, make sure that for CheckBox inside list item set focusable false

android:focusable="false"
android:focusableInTouchMode="false"

Solution 2:

old answer: I wrote in previous post here

android:focusable="false"
android:clickable="false"

will not help when ImageButton is in custom view.. One must use button.setFocusable(false); during runtime (from java source code)

Edit: There is even more elegant solution. Try to add android:descendantFocusability="blocksDescendants" in root layout of list element. That will make clicks onListItem possible and separately u can handle Button or ImageButton clicks

Solution 3:

For a ListView where you set the item views to CheckBox

android:focusable="false"
android:clickable="false"

http://code.google.com/p/android/issues/detail?id=3414