Get the scroll state of Listview
How can I get the scroll state of Listview?
I see the variable mTouchMode in class AbsListView which defines the scroll state, but it's not accessible.
I can listen to onScrol开发者_高级运维lStateChanged and save the state in my class as well but really would like to reuse the existing mechanism and not add more code.
The reason I want the scroll state is to dynamically update a list ONLY when the list is idle and not being scrolled.
Thanks.
Listening for onScrollStateChanged
and keeping state in your subclass is the officially Google-blessed way to do this (see API List demo 13, which loads data in a list only if the list is done scrolling/flinging). Like most Android views, I think it's intended that apps use event-driven code rather than polling of view state, and giving access to the internal scroll state outside of that would encourage bad polling-type behavior from developers.
精彩评论