We pretty much all know the nice technique apps like GMail / Facebook use to dynamically load more items to the ListView then you scroll to the bottom. In this post i want to shed some light on how to make such a list ourselves!
We can approach this from a few sides:
The first option is to add a button to the footer of the view. when pressed it will load more content.
The second option is to check if the last item is visible and load more content when it is!
I really like the second one, because i think its more user friendly. Android makes checking is a item is in view very easy because they added a function with the following method signature:
public abstract void onScroll (AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount)
As you might have guessed: with these parameters we can easily figure out whats the last item on screen! Before we make this method we will first have to add a footer to the ListView.
More after the breaky break!
Read more: Programmer XR