Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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