Skip to content

Instantly share code, notes, and snippets.

@enyachoke
Forked from pwittchen/endlessScroll.java
Created May 7, 2013 22:32
Show Gist options
  • Save enyachoke/5536714 to your computer and use it in GitHub Desktop.
Save enyachoke/5536714 to your computer and use it in GitHub Desktop.
public class EndlessScrollListener implements OnScrollListener {
private int visibleThreshold = 20;
private int currentPage = 0;
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
}
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
if (scrollState == SCROLL_STATE_IDLE) {
if (listView.getLastVisiblePosition() >= listView.getCount() - visibleThreshold) {
currentPage++;
downloadRecordsTask.setPage(currentPage);
downloadRecordsTask.execute();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment