How to implement endless list with RecyclerView?

前端 未结 30 3069
无人及你
无人及你 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:05

    I would try to extend used LayoutManager (e.g. LinearLayoutManager) and override scrollVerticallyBy() method. Firstly, I would call super first and then check returned integer value. If the value equals to 0 then a bottom or a top border is reached. Then I would use findLastVisibleItemPosition() method to find out which border is reached and load more data if needed. Just an idea.

    In addition, you can even return your value from that method allowing overscroll and showing "loading" indicator.

提交回复
热议问题