I have a listview and a custom adapter.
on my list view I set this :
lv.setOnItemClickListener(...)
All is working fine. But When I start scrolling it doesn't. While I scroll down slowly it is stable (onItemClick is called) but when I scroll down more quickly or scroll down & up several times quickly, selecting an item do not fire an event. But if I wait a little or keep clicking an item or slowly scroll to the top, it randomly works.
Sometimes when I click an item it displays the yellow background (and onItemClick not called). Sometimes the orange background stay even after I stop touching (and onItemClick not called). Sometimes the background don't change at all (and onItemClick not called). And sometimes it works.
The items of the list are made of several textView / imageview / linearlayout (I set for each focusable=false it changed nothing) dynamically inflated with a view holder.
Do someone has an idea of what is wrong or have an idea how to debug it ?
(The source code is too big to be pasted here, I can send you the source code or the apk if you wish)
Add this line to you parent layout of listview custom row xml file android:descendantFocusability="blocksDescendants"
Also in the textview of your inflator(Custom row view) layout just add:
android:focusable="false" android:focusableInTouchMode="false"
I had a similar problem. My ListView items consisted of a LinearLayout containing an ImageView and a TextView. In addition to the following for my layout:
android:descendantFocusability="blocksDescendants"
and the following for my TextView and ImageView, as suggested in another answer:
android:focusable="false"
android:focusableInTouchMode="false"
I also added this this to my ImageView:
android:clickable="false"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With