How to implement endless list with RecyclerView?

前端 未结 30 3107
无人及你
无人及你 2020-11-22 02:22

I would like to change ListView to RecyclerView. I want to use the onScroll of the OnScrollListener in RecyclerView to determine if a

30条回答
  •  甜味超标
    2020-11-22 03:20

    This is how I do it, simple and short:

        recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener()
        {
            @Override
            public void onScrolled(RecyclerView recyclerView, int dx, int dy)
            {
                if(!recyclerView.canScrollVertically(1) && dy != 0)
                {
                    // Load more results here
    
                }
            }
        });
    

提交回复
热议问题