Android – load more items at the end of grid view

I'm making an application and using the grid view to display all the images. The problem is that I have a lot of images, about 12000. I don't want to load them all at the beginning, because let's face it will always exist, so I want to know what's the best way to access the server to get more projects when GridView reaches the end

thank you.

resolvent:

To load more items, scroll to the end of the GridView

gridView.setOnScrollListener(new AbsListView.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){
                    // here you have reached end of list, load more data
                    fetchMoreItems();
                }
            }
            @Override
            public void onScrollStateChanged(AbsListView view,int scrollState) {
                //blank, not required in your case
            }
        });

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>