简体   繁体   中英

Android: Is it smarter to make 2 RecyclerViews or 2 Adapters?

I have a program I am writing where I have 2 tabs, when one is clicked, the recyclerview on the page updates with information X (Name, email, etc). When they click on the second tab it updates with information Y (phone, password, etc).

Is it better resource management / smarter to create 2 separate recyclerviews / adapters and change which is active? Or is it better to use 1 recyclerview with 2 adapters that adjust themselves dynamically?

My goal is to make it effective, manage resources efficiently, and also be able to change between the two very quickly.

-Pat

I would create a Fragment for each tab (could be the same class). Don't worry about the resources, recyclerviews are highly optimized.

For me its the more logical approach and it's easier to understand, especially for others if you're working in a team. Also you could change the view much easier and more dynamic in future, for example in a tablet/large screen view.

greets

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