Reputation: 2418
I add an OnScrollListener in a listView which contains 26 items.
@Override
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
if(mCurrentPosition == firstVisibleItem){
return;
}
System.out.println(firstVisibleItem);
}
When i scroll the list quickly(faster) onScroll doesn't call for every item. But when i scroll normally it's working fine.
System.out(30562): 0
System.out(30562): 1
System.out(30562): 2
System.out(30562): 5
System.out(30562): 8
System.out(30562): 11
System.out(30562): 14
System.out(30562): 18
System.out(30562): 20
System.out(30562): 23
System.out(30562): 26
Upvotes: 0
Views: 30
Reputation: 5176
Yes that is expected to happen. As per the documentation onScroll
is:
Callback method to be invoked when the list or grid has been scrolled. This will be called after the scroll has completed
So it's called only after your scroll is completed, hence when you scroll slow all the items are called for but when you scroll fast only those items are called which are currently visible after the scroll completes.
Upvotes: 2