onItemClickListener not working

Had list view using custom adapter and found that onItemClickListener would not work. Found answer in stackoverflow.

Apparently the listener won’t work if any row item contains a focusable or clickable view. The solution is the following line, which I inserted into the top section of the row item layout.


Apparently you can also do it programmatically:

listView.setDescendantFocusability(int focus);

where ‘focus’ is one of


Another solution – one I haven’t tried – is for situations such as having a button on the row that you want to keep clickable. In such a case you add the following line in the button’s xml.



This entry was posted in Android. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *