0

With the NavigationDrawer and the recommended way to implement it according to google it should be with fragments. Which creates a lot of nesting which does not seem to be too supported. And kind of messes up the idea of having activities with fragments for supporting different layouts.

So I wonder what the best suggestion would be if you have have a layout, that on a phone will be a list on the whole display, and on tablet you will have a list on the left side and detailed information about the item clicked on the right side? Ses images attached as links. It would have felt more natural to have activities instead of Fragment A, different for each layout.

https://www.dropbox.com/s/nwja0f60aje4hqe/fragments_one.png?dl=0

https://www.dropbox.com/s/a6smvdcq57g4ve0/fragments.png?dl=0

Fragment A is the fragment that your navigating to. Fragment B in both variants should be the same except for what's gonna happen when you click on an item. In the phone example the Fragment B should be an expandable list and on the tablet it should show the details in Fragment C.

Jemshit
  • 9,501
  • 5
  • 69
  • 106
peuhse
  • 1,688
  • 2
  • 20
  • 32

1 Answers1

0

What do you mean by "Which creates a lot of nesting which does not seem to be too supported."? Nested Fragments do have some different behaviour (e.g. the "for result" stuff is a bit trickier to do), but it's not that much different from an Activity with Fragments. Just always make sure that your Fragments are correctly attached and detached, then you can use them however you want. Some people don't like Fragments, because of their "lazy loadingness" and they're sometimes harder to see through, but that's just the cost for having a more flexible way to structure your components. It really depends what you want to do and how fit you are with the Android Framework.

einschnaehkeee
  • 1,858
  • 2
  • 17
  • 20
  • Well, this issue shows a little bit of what I mean: http://stackoverflow.com/questions/15608935/best-practice-for-nested-fragments-in-android-4-0-4-1-4-2-without-using-the. I have to struggle a lot with transactionmanager and childtransactions (well, I want to support from 4.1 so that's not really an option) instead of using an activity that either has one fragment or two depending on layout. Lot easier. With only fragments I have to control all fragments attaching and detaching and backstack. It will lead to code which is a lot less easy to understand and easier to loose your self in. – peuhse Apr 16 '15 at 14:15
  • @peuhse - Well I wouldn't say it's an issue, it's more the nature of Android's life cycle, that comes from it's message based asynchronous queue approach. In general, if you want more flexibility and decoupling, you have to do a bit more management of your components. – einschnaehkeee Apr 16 '15 at 18:27