Use PagedListAdapter inside NestedScrollView
Asked Answered
F

2

9

I have a RecyclerView that has a PagedListAdapter.

When I put the RecyclerView inside NestedScrollView the PagedList cannot compute the end of the list so start requests continuous burst for new data.

The main question is How should I use PagedListAdapter inside NestedScrollView?

Freon answered 28/5, 2018 at 10:3 Comment(0)
J
0

I had a similar problem, and it seems to be caused by the fact that NestedScrollView provides infinite dimensions and so RecyclerView will layout all its children. so I looked on github and found an implementation of NestedScrollView that solved the problem by passing View.MeasureSpec.AT_MOST down to the RecyclerView:

https://gist.github.com/danaimset/abacaa50d746a4537686a08ecc33c1a9

Juanjuana answered 19/2, 2020 at 13:9 Comment(0)
A
0

Based on Android documentation:

Never add a RecyclerView or ListView to a scroll view. Doing so results in poor user interface performance and a poor user experience.

The best new way is to use MergeAdapter. It added to Recyclerview v1.2.0alpha. So add this dependency:

implementation "androidx.recyclerview:recyclerview:1.2.0-alpha03"

If you want to put two Adapters in one recyclerView, follow this Guide:

then make an instance of MakeAdapter and pass your adapters on it then set it as RecyclerViewAdapter:

MergeAdapter ma = new (firstAdapter, secondAdapter);
myRecyclerView.setAdapter(ma);

If you have a layout and Pagedlist, follow this Guide:

Then Make and Simple ViewHolder and put the first layout on it. Then make MergeAdapter then add your layout's adapter and then PagedList's adapter, then add adapter of PagedList:

MergeAdapter ma = new MergeAdapter();
ma.addAdaper(simpleAdapter);
ma.addAdapter(pagedListAdapter);

then set this mergeAdapter to recyclerView's adapter;

myRecyclerView.setAdapter(ma);
Abbevillian answered 13/5, 2020 at 11:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.