What I want to do is to add data from the multiple data sources into single RecyclerView
but I don't know how to do it in Android Studio, can someone help me to understand this?
Asked
Active
Viewed 806 times
0

aminography
- 21,986
- 13
- 70
- 74

Farrukh Ehsan
- 25
- 6
-
2Hi Farrukh, the best way to get an answer to your question is to also post the code that is troubling you. Unless you've first tried solving it for yourself, you might not receive much help. If you've tried, post it here. – Ivan86 Nov 19 '19 at 03:07
-
Dear, I just try to learn that is it possible to publish data from two different data sources into into single recycler view and if possible then how ? – Farrukh Ehsan Nov 19 '19 at 03:15
-
I suggest looking into the topics: `recyclerview`, `recyclerview adapter` and `local/remote repositories`, I believe that could help you. – Ivan86 Nov 19 '19 at 03:25
2 Answers
0
Farrukh Ehsan,
You haven't mention how far you try.
First of all, yes. It is possible.
There are some question:
- How data come local or form server?
- Is it come in same time or different?
Assume that your data will come different time, that means your data will update after binding data to recyclerview adapter and it is server data.
so, you have to modify data object and marge data on update your data then re-bind data on adapter and re-set to recycleview.
if your data come once then marge data that you got from different data source the bind to adapter and set to recycleview.

Md. Enamul Haque
- 926
- 8
- 14
-
Thank you so much for reply, I am want to get it from two different Firebase Firestore collections. – Farrukh Ehsan Nov 19 '19 at 03:43
-
Ok, you obviously using data model to show data in recycle view. parse data from different data source and marge them in single data object and set to recycleview. – Md. Enamul Haque Nov 19 '19 at 03:48
-
-
Here is the link https://stackoverflow.com/questions/26245139/how-to-create-recyclerview-with-multiple-view-type – Farrukh Ehsan Nov 19 '19 at 10:43
0
Make a list of type Object
and add all the models that you want to have in Recyclerview. Now in Recyclerview's adapter make separate ViewHolder
class for each type of data sources. It somewhat like showing Admob ads in Recyclerview items.

abhi
- 961
- 9
- 13