得到一个事件时,ListView项是可见或不可见 [英] Get an event when a ListView item is visible or not
问题描述
我想知道是否有某种OnVisibilyChangeListener的观点在ListView,因为我想有一个叫做每次ListView项更改其可见性的方法。
I was wondering if there is some kind of OnVisibilyChangeListener for views in a ListView because i would like to have a method called every time a ListView item change its visibility.
我知道了在preDrawListener检查,如果认为是要去可见。但是,我怎么能检查视图获取滚动的屏幕可视面积呢?
I know about the OnPreDrawListener to check if the view is gonna be visible. But how can i check if the view gets scrolled out of the visible screen area?
推荐答案
您可以实施 OnScrollListener
的ListView和覆盖<一href="http://developer.android.com/reference/android/widget/AbsListView.OnScrollListener.html#onScroll%28android.widget.AbsListView,%20int,%20int,%20int%29"><$c$c>onScrollStateChanged(AbsListView看来,INT scrollState) 和<一href="http://developer.android.com/reference/android/widget/AbsListView.OnScrollListener.html#onScrollStateChanged%28android.widget.AbsListView,%20int%29"><$c$c>onScroll(AbsListView看来,INT firstVisibleItem,诠释visibleItemCount,INT totalItemCount) 并得到ListView项是可见的。
You can implement OnScrollListener
for ListView and override onScrollStateChanged(AbsListView view, int scrollState)
and onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount)
and get the ListView item that is visible.
onScroll(AbsListView观点,诠释firstVisibleItem,诠释visibleItemCount,INT totalItemCount)
是,这将有助于你知道哪些ListView中的一行是使用的价值可见的方法 firstVisibleItem
和 visibleItemCount
。
onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount)
is the method that will help you to know which row of ListView is visible by using value of firstVisibleItem
and visibleItemCount
.
这篇关于得到一个事件时,ListView项是可见或不可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!