How to create multi-layered RecyclerView adapter? - android

In my Android project I have a complex RecyclerView. The structure of my RecyclerView looks like the attached image.
In a few words, I have a main RecyclerView which contains a CardView, within the CardView I have another RecyclerView and each element can expand and collapse.
I have tried using a nested RecyclerView implementation (which is easy to find in Google by typing "Nested RecyclerView"), but this implementation has a bottleneck. When I call onBindViewHolder it calls setAdapter method and causes a bug when I scroll the RecyclerView.
Could you please give me any tips on how to implement such RecyclerView? What is the best way of building such Recycler adapters?
Here is an image how it looks like
Here is what I found about my way of implementing RecyclerView

This can be easily done with Concat Adapter.
https://www.youtube.com/watch?v=n_mrrva_z
this is my Mockup app using Concat adapter.
Think of Concat Adpater as an arrayList. Its coded like ConcatAdapter(HeaderAdapter, Adapter2, HorizontalAdapter)

Related

Android Architecture Components and sectioned RecyclerView

Hi all dear android developers
im new to android, i started android developing with the android-room-with-a-view-kotlin demo, it works good and no have any problem, but i want to add section headers in recyclerview by first letters. i can create a sectioned recyclerview (multi type content recyclerview like this), but my main problem is implementing a sectioned recyclerview that works whit ViewModel, Room, LiveData and ... . now how i do it?
thanks to all.
Not sure what do you mean by sectioned recyclerview, maybe you mean a recyclerview that has custom views? In general you just need to implement a custom adapter for the recyclerview. I wouldn't suggest using LiveData too much, it is very limited in the things you can do, instead use observables. Here is the official documentation on how you can create a custom adapter for the recyclerview.

How to implement Horizontal RecyclerView With Header in my Android app

I would like to know the best approach to create an interface similar to the one in the image. I am using the FirestoreRecyclerAdapter to populate my list. Should I have a TextView for each category an then a RecyclerView under that category? I have multiple view types one for the header an one for items but I would have to know when to add a header in between the items. Also note for my purposes a item can fit multiple categories.
Here's a tutorial for implementing such RecyclerView. You might also consider looking at the github repository as well.
The idea is simple and effective which is described in the tutorial. You need a mother RecyclerView inside a NestedScrollView. The parent RecyclerView will have child RecyclerView holding the items to be shown in each row. Just follow the implementation of the SnapAdapter and the Adapter class for the mother and child RecyclerView respectively.

Expanding recycler view items

I have gone through other questions as well but couldn't figure out something. I have a well set up RecyclerView.
I m trying this library: https://github.com/AAkira/ExpandableLayout
Now I want the items to be expandable so that they show a TextView which is different for each item.
But I can't figure out how to place itms in XML. Where to place RecyclerView and where the expandable layout? How to setup these things?
Take a look at one of the samples given in the library, it is called 'examplerecyclerview' which I think is the one you need.
These are specific files that you should watch:
RecyclerView Activity and Adapter (Java)
RecyclerView Activity (XML)
RecyclerView List Row (XML)

Android List view row move vertical

I want to create List view row animation like below . I want to move row from one list view to other list view. Both list view are in same activity.
Anyone can give me idea how I can do this.
First of all because you mentioned "ListView":
In my opinion the best way to perform dynamic "lists" in android is to use to android-given class
RecyclerView.
It's easy to use like a normal ListView but like I said before it handles dynamic data.
Moreover it has some support librarys like ItemTouchHelper to drag/drop and swipe items in the list around. Its very easy to expand your RecyclerView with this upgrade. Here is a good tutorial:
Tutorial.
I would like to give you two ideas how I would proceed to implement such a list like the example of your post:
1) (Recommended) Search on Github or similar sites for 3rd library parties that already solved this.
2) Use the RecyclerView with the ItemtouchHelper-Upgrade i mentioned above and try to expand it with two lists. When an item is onMove() set the visibility of the first list on GONE and the second on VISIBLE. Now you only have to add the data of your item to the second list and remove it from the first. Then use notifyDataSetChanged() on both lists and your done.
I dont know how difficult it will be to implement it but thats the only way I know how you can do that and how the programmers of your example could have done it.

Android: List of CardView

How can I create a list of CardView(s) like the one in the photo? Do I need a RecyclerView or not?
if you want it to look excactly like it is in the uploaded image then you would need either a listview and an adapter with a cardview layout or a recyclerview and a cardview layout, it is basically the cardview that gives the items that good elevated feeling otherwis the rest is the same, but i suggest you use a recyclerview since google is replacing the traditional listview with all recycler, here is a great tutorial you can use http://code.tutsplus.com/tutorials/getting-started-with-recyclerview-and-cardview-on-android--cms-23465

Categories

Resources