/** * Detects when user is close to the end of the current page and starts * loading the next page so the user will not have to wait (that much) for the * next entries. * * @author Ognyan Bankov */ public class EndlessScrollListener implements OnScrollListener { // how many entries earlier to start loading next page private int visibleThreshold = 5; private int previousTotal = 0; private boolean loading = true; @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (loading) { if (totalItemCount > previousTotal) { loading = false; previousTotal = totalItemCount; } } if (!loading && (totalItemCount - visibleItemCount) <= (firstVisibleItem + visibleThreshold)) { // I load the next page of gigs using a background task, // but you can call any function here. loadPage(); loading = true; } } @Override public void onScrollStateChanged(AbsListView view, int scrollState) { } }
소스 참고 : https://github.com/ogrebgr/android_volley_examples/blob/master/src/com/github/volley_examples/Act_NetworkListView.java