简体   繁体   中英

How to create multiple recyclerViews?

This is not duplicate of How to create RecyclerView with multiple view type? There are question on SO for different views for different row in same list but this is not the same.

This is a very simple question as I am a beginner to android development and OOP as well.

I have multiple(three) tabs in my android app and each tab has a list of items inside it (like in whatsapp). I have successfully created a list(not listView) using recyclerView in one of the tabs. Now I want to create another list under the second tab but I have to use the previously used adapter. I don't know how to use onCreateViewHolder() to return multiple holders.

I tried if(object instanceOf class) inside getItemViewType() but I dont know how to access the object for comparison.

You can use the same adapter in all the three tabs. And for Recycler View you can use 3 different objects for those 3 tabs. This process might help in creating multiple Recycler Views.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM