Zhao Lin Zhao Lin - 25 days ago 12
Android Question

OnItemClickListener is not working for ListView in Android Fragment

I have implemented OnItemClickListener in Android Fragment.

when i have implemented at beginning, it was working.

But yesterday i have put some ui objects in list item, after that onItemClickListener is not being called.

I have tried all day and but i did not find the solution yet.

i hope help from some who has experience in that.

Answer

The problem is that some ui objects in list item takes focus so main list item can not get focus.

So you need to block all focuses in sub ui objects in list item.

You can add this

      // code formate
      android:descendantFocusability="blocksDescendants"

to list item xml file.

I hope it will help you to fix

Comments