Android Dynamically load Listview at scroll end?

后端 未结 6 1950
梦毁少年i
梦毁少年i 2020-12-04 07:37

I am loading a listview from Http server, 20 at a time ,At the end of Listview I a want to load next 20 data from server and this process will continue till

6条回答
  •  天涯浪人
    2020-12-04 08:03

    This is what I used to load more data at the end of the listview

            listview.setOnScrollListener(new OnScrollListener(){
    
            @Override
            public void onScroll(AbsListView view,
            int firstVisibleItem, int visibleItemCount,
            int totalItemCount) {
            //Algorithm to check if the last item is visible or not
            final int lastItem = firstVisibleItem + visibleItemCount;
            if(lastItem == totalItemCount){                 
            // you have reached end of list, load more data             
            }
           } 
            @Override
            public void onScrollStateChanged(AbsListView view,int scrollState) {
            //blank, not using this
            }
            });
    

提交回复
热议问题