Created
December 19, 2013 18:29
-
-
Save BlaShadow/8043905 to your computer and use it in GitHub Desktop.
How to know if list is scrooling down or up #Android
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setOnScrollListener(new OnScrollListener(){ | |
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { | |
// TODO Auto-generated method stub | |
} | |
public void onScrollStateChanged(AbsListView view, int scrollState) { | |
// TODO Auto-generated method stub | |
final ListView lw = getListView(); | |
if(scrollState == 0) | |
Log.i("a", "scrolling stopped..."); | |
if (view.getId() == lw.getId()) { | |
final int currentFirstVisibleItem = lw.getFirstVisiblePosition(); | |
if (currentFirstVisibleItem > mLastFirstVisibleItem) { | |
mIsScrollingUp = false; | |
Log.i("a", "scrolling down..."); | |
} else if (currentFirstVisibleItem < mLastFirstVisibleItem) { | |
mIsScrollingUp = true; | |
Log.i("a", "scrolling up..."); | |
} | |
mLastFirstVisibleItem = currentFirstVisibleItem; | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment