I need to check the direction of the scroll when my listview is scroll up or down, I am getting it as:
int lastVisibleItem = 0;
boolean isScrollingDown = false;
void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
if (firstVisibleItem > lastVisibleItem) {
isScrollingDown = true;
Log.e("logkey","down");
}
else {
Log.e("logkey","up");
isScrollingDown = false;
}
lastVisibleItem = firstVisibleItem;
}
The problem is when the visible items are equal to the screen or when there are items to the whole screen suppose that only 6 items fit in the screen and the last item is half visible, the log cat starts showing me the both down and up at the same time!
In simple words, in the above case, the scroll direction is ambiguous to get when there are items equal to the screen to fit in and the very last item is half visible and when I scroll I am getting this problem!
Can somebody please tell me what I am doing wrong? Thanks in advance!