问题描述
我有一个OnScrollListener
和OnItemClickListener
的ListView.当我单击一个项目时,会同时触发OnScrollListener
和OnItemClickListener
中的onScroll()
方法.
I have a ListView with an OnScrollListener
and an OnItemClickListener
. When I click on an item, both the onScroll()
method in the OnScrollListener
and the OnItemClickListener
are fired.
是否有防止这种行为的方法?如果没有,我怎么能在onScroll()
内分辨出用户是否真的在滚动或只是在单击?
Is there a way to prevent this behaviour? If not, how can I tell, inside onScroll()
, if the user is really scrolling or he's just clicking?
推荐答案
我认为onScrollStateChanged
也应通过滚动调用.然后,您应该能够查看状态是否处于空闲状态或滚动浏览常量(在OnScrollListener
中定义).有关示例,请查看本主题.
I think onScrollStateChanged
should also be called with scrolling. Then you should be able to see if the state is idled or scrolling through the constants defined in OnScrollListener
. Check this topic for an example.
这篇关于在ListView中单击项目时调用的OnScrollListener.onScroll()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!