RecyclerView with different Cardview that hold other list in them - android

I have a recyclerView with two cardView one with plain text and the other with a list of data which is not specified. I have no problem creating two different view holder and set one single text data on first. The problem is how to load a list inside the 2nd cardView. Is it possible to create a list view adapter inside a recyclerView adapter ??

You should implement Custom LayoutManager for that. Refer this answer for an example and explanation of how to do that

Please post your code so that we can better understand your issue.
You can place a recycler view inside the second card view. And you can override getItemViewType() in adapter to handle the two card views.

Related

Android RecyclerView RecyclerViewPool

I am trying to understand how RecyclerView works.
We know that when RecyclerView needs an ItemView, that RecyclerView's adapter provides the ItemView. To do so, the adapter first looks for that type of view inside some caches and at last inside the RecyclerViewPool (Check this blog for the full list of checking). If the adapter doesn’t get the specified type of view inside the cache's or RecyclerViewPool, then it creates one inside the onCreateViewHolder method.
Now my question is, is there any way to check constantly, while scrolling the RecylerView list, what views are inside the RecyclerViewPool?
Any help will be appreciated. Thank You.

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.

List(with out scroll) inside a RecyclerView row

I want a list inside a recycler view, I don't want nested scroll, what is the best approach for this?
What I am considering now is that dynamically add the inner list rows.
If that is the case, let the adapter hold the whole data for the inner list. The number of list rows in each row of the recycler view row is not fixed.
Please voice your opinions with pros and cons.
NB:- I dont have any code to post since I am working on this.
Inside List View you need to Disable scrolling.
i.e listview.setNestedScrollingEnable(false);

What are the responsibilities of, and differences between, a RecyclerView Adapter and RecyclerView LayoutManager?

I am trying to understand the RecyclerView but I can't understand the difference between the Adapter and LayoutManager.
Can anyone explain it to me?
The adapter is used to create (and bind data to) views that correspond to each item in your dataset.
The layout manager is responsible for the layout of these views.
The adapter doesn't know how the views will be positioned and sized. This means you can swap the layout manager without having to change your adapter code e.g. switching from a LinearLayoutManager to GridLayoutManager.
Check out this answer for a deeper (though still high-level) explanation (scroll past the initial code block to the section about RecyclerView philosophy):
ListView to RecyclerView Migration for CustomView
So in Recycler View you need an Adapter to manage the data which will contain the Recycler view. Adapter will take the data it can come from internet or from internal database, than adapter fetches the dat when it gets the data without an error it comes back to adapter(e.g.adapter grabs data from dataset) then it shows the data in the View Holder in your card like a one cell in the Recycler View, View Holder is a class that manages the view and than that view appears in the Recycler View. The above image which i tried to draw shows that process for Horizontal Recycler
In my case i found these benifits when i working on them
Basically an Adapter is used to gather all corresponding data what you provided
to all views defined by you
after gathering all data it wants a layout to display thease views for this layoutmanager gives a flatform to show them .

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)

Categories

Resources