How to implement add on-demand footer in ListView when loading data

all. I want to show the footer as "Loading ..." when the user reaches the bottom of the list. Now I managed to determine when we are on the last element. Then trouble comes. We need to configure the footer before configuring the adapter, we need to hide it later. Anyone have a solution? Perhaps this question has already been discussed, but I did not find the answer.

+5
source share
2 answers

you can add footer before installing adapter with

listView.addFooterView(yourFooterView, null, true);

* Please note that the parameters should match your purpose.

OnScrollListener onScroll :

public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount){
    int lastItem = firstVisibleItem + visibleItemCount;
    if(lastItem == totalItemCoun){
        // fill your next set of items
    }
}

, , , . , ,

lv.removeFooterView(yourFooterView);

,

+4

, question, setFooterView , setFooterView removeFooterView onScroll , , , .

+2

All Articles