Reputation: 17083
I have a working app that does not have any fragments.
But DevBytes says if you're not using fragments in you application you making a big mistake.
The API Guides says to Add multiple fragments to a screen to avoid switching activities
From that I assume we should always use fragments.
In my app I have activities A, B, C and D
A is map activity in which I show some markers and some info in the InfoWindow.
B has the same information as A but using just a ListView, so I can show more information about each item I have for the user.
C is the details of the selected item. The user can get to C either from A or from B
D is just another activity (outside of the flow)
Although I don't use fragments today, it seems reasonable to convert A and B to fragments so they can be reused if some day I decide to show A and B side by side in a tablet (even though it's could be easily done without fragments).
So my question is: should I also turn my C activity into a fragments as it's part of the flow? (even if I don't plan to reuse this activity) And if the answers is yes, should I also turn D into a fragment and have one app with one activity and 4 fragments?
Thanks for you time.
Upvotes: 3
Views: 288
Reputation: 17800
You should use fragments. If you don't, you're adding to future development time and decreasing future flexibility. You may not need to use fragments right now, but doing so will pay off in spades. Keep it simple by mimicking Google's own SimpleSinglePaneActivity. This will allow you to quickly implement the phone UI first, while making the tablet UI much simpler to implement some time in the future.
Upvotes: 3
Reputation: 28152
Depends on what you are trying to achieve. If you aren't updating the user interface in any way I won't recommend opting to fragments but if you want to update the UI then fragments offer some cool stuff. For example if you on a tablet want list and detail showing up simoultanously you'd have to convert A, b and C to fragments.
Upvotes: 1