You can set a OnScrollListener
on your ListView
. In the onScroll()
method, check if:
firstVisible + visibleItemCount = totalItemCount
If this condition is satisfied, you can load more items from the database, reinitialize the adapter with the updated list of items.
listView.setOnScrollListener(new OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {}
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
if ((firstVisibleItem + visibleItemCount) == totalItemCount) {
// add 20 more items to the list and reinitialize the adapter
}
}
});
}