dynamic listview adding “Load more items” at the end of scroll

you try the following code

list.setOnScrollListener(new OnScrollListener() {

        public void onScrollStateChanged(AbsListView view, int scrollState) {


        }

        public void onScroll(AbsListView view, int firstVisibleItem,
                int visibleItemCount, int totalItemCount) {

            if(firstVisibleItem+visibleItemCount == totalItemCount && totalItemCount!=0)
            {
                if(flag_loading == false)
                {
                    flag_loading = true;
                    additems();
                }
            }
        }
    });

in the additem() add the next 10 items to array list and set the flag_loading as false. and call notifydatasetchanged. it should work.

Leave a Comment

tech