Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android ListView touch-animation gone when onClickListener is attached

I have a ListView with a custom layout for the child items.

Without the OnClickListener attached to the items each item highlights nicely when the user touches it but as soon as I attach the listener the animation is gone. The listener is working but then there is no animation or visual feedback. The same problem occurs when I use an OnTouchListener.

What can I do to grab the onClick-Event but still have the default animation?

like image 520
ShadowMare Avatar asked Sep 29 '22 01:09

ShadowMare


1 Answers

With ListView you should use OnItemClickListener. If there's is a specific reason for using OnClickListener, you can manually fire the item click event. In your OnClickListener call performItemClick.

like image 164
Zielony Avatar answered Oct 03 '22 07:10

Zielony