Last active
December 5, 2018 08:03
-
-
Save yusuphwickama/ad25e7aaa651b137aae617d609219869 to your computer and use it in GitHub Desktop.
Load more items on a list view when scrolling to the bottom.
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
boolean isLoading = false; | |
listView.setOnScrollListener(new AbsListView.OnScrollListener() { | |
@Override | |
public void onScrollStateChanged(AbsListView absListView, int scrollState) { | |
if (listAdapter != null && | |
scrollState == SCROLL_STATE_IDLE && | |
listView.getLastVisiblePosition() == (listView.getCount() - 1) && | |
!isLoading && (listAdapter.getCount() != itemsProvider.getTotal())) { | |
isLoading = true; | |
// Get more items and add them to the adapter | |
isLoading = false; | |
} | |
} | |
@Override | |
public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) { | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment