Code example for ListView

Methods: setOnScrollListeneraddFooterView

    public void onViewCreated(View view, Bundle savedInstanceState) {
        // Set up our loading indicator at the foot of the ListView. 
        mProgressBar = new ProgressBar(mParentActivity);
        mListView = getListView();
        mListView.addFooterView(mProgressBar, null, false);
        // Set our adapter. 
        // Set a scroll listener to load more if we are at the end of our list 
        // and less than two items are offscreen. 
        mListView.setOnScrollListener(new OnScrollListener() {
            private int visibleThreshold = 2;
            private int previousTotal = 1;
            private boolean loading = true;
            public void onScroll(AbsListView view, int firstVisibleItem,
            int visibleItemCount, int totalItemCount) {
                if (loading) {
                    if (totalItemCount > previousTotal) {
                        loading = false;