Skip to content

Instantly share code, notes, and snippets.

@pwittchen
Last active December 12, 2015 09:58
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save pwittchen/4755171 to your computer and use it in GitHub Desktop.
Code Snippet responsible for Endless Scroll View in Android ListView.
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