I want to create a chat activity that will use data from Firestore database and display messages in two different layouts.
For that I'm gonna need an adapter
with multiple view types. Tried using a single view type and hiding TextViews
and it resulted in display problems in the app.
I found solutions to create such an adapter for either Firebase Realtime Database or javascript, but I can't find any for Firestore Database and Java using Android Studio. How should I proceed?
swapAdapter
?
Basically set a simple a simple firestore and all the required instances like RecyclerView
, Model
, ViewHolder
, adapter1
, adapter2
, etc...
this is a very good example: How to display data from Firestore in a RecyclerView with Android?
and then use swapAdapter
to swap the current adapter with the provided one. It is similar to setAdapter(Adapter)
but assumes existing adapter and the new adapter uses the same ViewHolder
and does not clear the RecycledViewPool
.
docs: https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/RecyclerView#swapadapter
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.