You should use onScrollListener and depending on how many items that are left you load more. IE by calling the webservice with index numbers, start and end.
Here is an example I have used: In this example I always fetch the next 15 items from the server. and the first if case is that it starts fetching new items when there is only x number of items left. X is 2* the number of visisble items on the screen. It depends on the screen density.
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
if((totalItemCount-(firstVisibleItem+visibleItemCount) <= visibleItemCount*2)) {
startNumber = totalItemCount;
endNumber = startNumber+15;
if(fetchclass!=null) {
if(!fetchclass.isRunning()) {
fetchclass= new fetchNewsClass();
fetchclass.execute(startNumber,endNumber);
}
}
else {
fetchclass = new fetchNewsClass();
fetchclass.execute(startNumber,endNumber);
}
}
}
startNumber and endNumber is just index numbers that I use to call the webservice to get the correct data from the server. fetchclass is the AsyncTask that I use to fetch the data.