everyone. I want to show the footer like "Loading..." when user reaches bottom of the list. Now I only managed to determine when we are on the last element. Then trouble comes. We need to set up footer before setting adapter, we need to hide it afterwards. Does anyone have solution to this? May be this issue is already discussed, but I haven't found an answer.
you can add the Footer before setting the adapter with
listView.addFooterView(yourFooterView, null, true);
*Note that the parameters should suit your objective.
Then you activity could implement OnScrollListener
and on the method onScroll
you can get the last item like this:
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount){
int lastItem = firstVisibleItem + visibleItemCount;
if(lastItem == totalItemCoun){
// fill your next set of items
}
}
After the new set is filled, the footer will go to the bottom again, so you dont have to hide it. However, if you want to remove it you can use
lv.removeFooterView(yourFooterView);
I hope this helps
you can, as proposed on this question, call the setFooterView before setting adapter and remove it just after, and then use setFooterView and removeFooterView in onScroll as needed. This works and I have tested it, in aforementioned page there are other solutions proposed as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With