It really depends on how you want your application to flow.
Consider a scenario in which a user does the following:
- Begins your first action.
- Click the second tab
- Click on the third tab.
- Presses the back button
If you use a separate action for each screen, the following will happen:
- Action 1 starts
- Action 2 starts
- Action 3 starts
- Action 3 is closed, the user returns to Activity 2
(in this case, return the "Back" button again, you will return to "Activity 1", and press it again).
If you used one action for all tabs, the following will happen:
- Action 1 starts
- Step 1 sets the contents of the tab for the contents of tab 2.
- Step 1 sets the contents of the tab for the contents of the tab 3.
- Step 1 is closed, the user returns to the main screen
If you use a tabbed screen, the second method is preferred (one action with TabHost
or similar), otherwise the user will end up making a large stack of activity simply by switching between tabs (that is, if they switch between tabs a lot, they will have to click the button repeatedly "Back" to exit).
If you want to move on to one approach to work, do some research on TabHost
and TabContentFactory
. In your factory's createTabContent
method, you can inflate the view / layout from XML to set it as the contents of the tab using View.inflate
. Look at them and come back, ask another question if you are stuck;)
source share