How do I build a screen where I have a vertical recyclerView and its items are horizontal recyclerView but using paging 3?
I don't know how to pass the pagingData into the childAdapter
Related
Iam using nested recyclerview
I need to get data of parent recyclerview when I clicked child recyclerview its possible..
Iiam using Firebase recycler adapter
There is no reason you need to have nested recyclerview's and it does slow down performance because it was intentionally designed not to be nested(Although it does actually show correctly).
How can I implement this kind of UI, where we have two recyclerViews. One scrolls horizontally and the second one vertically. when the second one scrolls first one also scrolls top together.
I tried to implement using NestedScrollView, but I had to make second recyclerView height wrap content which causes recyclerView not recycle.
The second way that I tried was having one recyclerView. And adding horizontal recyclerview as a header. The problem was to save header recyclerview scroll state when navigation. And there had been crashes when loading next page (paging 3) in header recyclerView.
The question is: Is there any optimal solution for this kind of ui?
In cases, Like this, you don't have to use 2 RecyclerView and you also have to avoid using RecyclerView insideScrollView. instead of this you have to use one vertical RecyclerView with multitype view Adapter.
in this way, you are going to have 2 different ViewHolder one of them is a horizontal recyclerView (your top item) and the other one is your other items.
for learning multitype adapter you can see this:
How to create RecyclerView with multiple view types
and for a horizontal recyclerView inside a vertical RecyclerView you can see this :
https://medium.com/#ashishkudale/android-list-inside-list-using-recyclerview-73cff2c4ea95
you have to combine these 2.
I could not understand the meaning of "header" where you said "adding horizontal recyclerview as a header" but if you did what I told and the problem is the state of inner Horizontal recyclerView, I think probably you are calling setAdapter method of horizontal RecyclerView in OnBind() method of your vertical recycler view, it is a common mistake that I have seen in many tutorials.
if you have done this mistake , try to call setAdapter of your inner recyclerView in the constructor of its viewHolder and just update the list using yourHorizontalAdapter.notifyDataSetChanged() in onBind() method of VerticalRecylerView,
and if its not the case and your recyclerView is completely destroying see this link :How to save RecyclerView's scroll position using RecyclerView.State?
My architecture is MVVM. For implementing paging I used paging library from architecture component.
I need paging for outer recycler view and inner recycler view. For outer recycler view I successfully implemented it, but for inner recycler view I don’t know how to implement.
I implemented paging like in this article for outer recycler view
https://proandroiddev.com/8-steps-to-implement-paging-library-in-android-d02500f7fffe
UPDATE
I implemetened my inner recycler view like this example and it works, but I think it's not preferable solution
how to use paging when recyclerview item have another recyclerview
Just add ViewPager inside your ViewHolder item view, and do all ViewPager logic inside onBindViewHolder()
I have a nested recyclerview and both have a horizontal linear layout but the child one is not scrolling
All consequences
1) I'm using a snap helper in the parent recyclerview
2) also using recycler view pool in child recyclerview
It is bad practice to use a Nested RecyclerView with the same LayoutManager.
If horizontal scrolling is important to use for you then try RecyclerView inside ViewPager.
This will behave like this:
When scrolling RecyclerView, Fragment will stick to port until RecyclerView last item is shown. After that the next fragment switchs.
I have RecyclerView where each item represent CardView, and each CardView contain RecyclerView with GridLayoutManager or LinearLayoutManager,
I don't want to go with RecyclerView inside RecyclerView, want to have a one RecyclerView and to achieve the CardView effects(margins,elevations) using different viewTypes, or ItemDecorators. Is it the right approach? and samples could be useful.