I have a two pane master-detail style application with differing views for the tablet and phone version. Is it recommended to have a single activity switching fragments in the phone layout or is it better practice to have two activities, one with each fragment? The android examples have both ways implemented but i am not sure which is the best practice and why?
Afaik, the example of dual pane showed in the official documentation specifies 2 fragments and 2 activities, but this isn't a choice you have to do. Both are required.
I use fragments for this. On a phone, there's a viewpager which lets the user switch between fragments. On a tablet, fragments are shown at the same time. But of course, it all depends on what your app does.
Depending on your app and on the users, you can have a tab bar that lets users switch the viewpager.
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.