ListView Long Click Animation

∥☆過路亽.° 提交于 2019-12-07 20:48:33

问题


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?


回答1:


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.




回答2:


Make sure the enclosing list item's view specifies:

android:background="?android:attr/selectableItemBackground"


来源:https://stackoverflow.com/questions/1840721/listview-long-click-animation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!