0

I am designing a Native Android app which should give a single page feel for the user. I have already sketched the interface thus:

Home page

Sub page

My question is this: Is it wise to use a single activity with multiple fragments, changing the contents for an area on the activity each time a new page is selected or is there a way to add all buttons to several activities which will be loaded based on the selected button?

Thanks for your help in making this decision.

Ibrahim Lawal
  • 1,168
  • 16
  • 31
  • 1
    You should do some research on using fragments vs activities. You'll find lots of info on stackoverflow about it. The general idea is, fragments are used to create re-usable user interfaces, while activities represent a specific...well...activity within the app. So in the case of your design, you would use fragments within a viewpager, which is attached to an activity. If the user selected something and went to a search or a settings page or something similar, you would launch a new activity since that is a new context for the user. – NoChinDeluxe Jul 26 '16 at 20:29

2 Answers2

3

I am already lost in your navigation - i think you want to show too many sub fragments on the same screen.

But if you want to stay with this navigation type I would recommend one activity with many fragments. The Fragments are there exactly for the situation (and many other situations;) ) when you don't want to change the whole screen but only a part of it!

petin
  • 629
  • 5
  • 13
  • Wow, lost? It's supposed to be just a top row of tabs and a bottom row visible only when one of the top row items is selected – Ibrahim Lawal Jul 27 '16 at 09:18
  • First of all, in tabhost one item should be selected every time. I personally don't prefer nested navigation - that's why i said that I am lost. What happens if you select the second tab and after that you return to the first tab, which nested tab will be selected? The last selected or the default selected? Thats the situation why are there so many navigation types - drawer, tabhost, bottomBar. As you can se the google playstore app, they use same hierarchy as you, but when you click on a nested tab, you will be redirected to new activity (fragment), where the main tabs are no more present – petin Jul 27 '16 at 09:44
  • Awesome! Thanks for the insight – Ibrahim Lawal Jul 27 '16 at 13:31
1

That's one of the reasons Fragments were created, it is advisable to use them in such circumstance.

Yes, you could separate out each layout as a new activity, but you'd have to reload the entire display when switching rather than just the section dedicated to the Fragment to which you're switching. In that case, you'd have to recreate your buttons every time you load a new view.

Glen Pierce
  • 4,401
  • 5
  • 31
  • 50