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.
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?
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 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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With