I would like to capture long click events in a ListView, which was easily done using a OnItemLongClickListener. However, that lacks the fading animation of the selector transitioning to a long press that is seen when the long click is handled by onCreateContextMenu. How can I get that animation using OnItemLongClickListener
?
Asked
Active
Viewed 5,175 times
2
-
I had the same problem. This answer helped me a lot. https://stackoverflow.com/questions/6833844/why-does-calling-setbackgroundcolor-on-a-view-break-its-long-click-color-change/6945791#6945791?newreg=f1cc9feb32c84863a4a8ac1bf75253e6 – fcosta-ian Apr 24 '15 at 19:29
2 Answers
3
Make sure the enclosing list item's view specifies:
android:background="?android:attr/selectableItemBackground"

gladed
- 1,705
- 1
- 17
- 25
2
I was having the same problem and resolved it by removing the following property in the LinearLayout for my rows:
android:clickable="true"
Removing that property or setting the value to false both fixed the problem.

Jeb
- 599
- 6
- 7
-
Indeed it does not. Why would it? All that happens is that the long-click stops working, as you'd expect. – Alex Gian Feb 27 '17 at 03:04