OnItemClickListener on a ListView inside a Fragment not working

Dunnow picture Dunnow · Feb 15, 2013 · Viewed 29.3k times · Source

EDIT: SOLVED. If there's anything focusable in the XML of the items, it will break the touch of the list, in other words, android:focusable=false to all the checkboxes, switches or anything like that of ur list. And done =)

Ok so, here's my problem.

I wrote a app that uses tabs and fragments, and it all goes the way I want except for the thing that when I try to capture a onItemClick on a listView it does not even mark the row as touched/pressed/selected.

I've been reading a little bit about and many people have the same issue, but I did not found any responses that helped me at all.

I don't want to implement a ListFragment, in fact I don't even know how/why I should, and since all my code is already working, I don't know if implementing one will give me much more work to do, so, here it is:

Is it possible to implement a listener for a click on a listView, inside a fragment? and if it is, HOW?

PD: minSDK=14, tatgetSDK=15

Answer

Ashwin S Ashok picture Ashwin S Ashok · Dec 9, 2013

Just put

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

in layout. For all textviews,buttons etc.