Tabs, Actions, and Nested Snippets

I am starting a new application and should have a set of tabs. Inside each tab, I need several screens, each of which has its own back stack (required by the client). Here is a brief diagram of what I mean:

Tab 1 | |_Screen1a --> Screen1b --> Screen1c Tab 2 | |_Screen2a -->Screen2b Tab 3 | |_Screen3a --> Screen3b --> Screen3c --> Screen3d ...etc 

Now I have done this before using FragmentActivity as the activity of the tab node. Each tab was then a FragmentActivity in which each fragment was placed. By this I mean the following:

 FragmentActivity FragmentActivity1 | |_Fragment1 --> Fragment2 --> Fragment3 FragmentActivity2 | |_Fragment4 --> Fragment5 FragmentActivity3 | |_Fragment6 --> Fragment7 --> Fragment8 --> Fragment9 ...etc 

Now that version 4.2 of the SDK and the new version of the support library are released, there are nested fragments. This allows you to place the fragment inside another fragment (I assume that you can continue nesting, although you have not tested it yet). I was thinking of switching to using nested fragments, as I am currently using deprecated methods in my tab activity. Essentially, I would have had the whole thread of my application implemented in fragments with one host activity.

Are there any problems in terms of performance, memory problems, etc.? Or should I go with the implementation I did before and use deprecated methods?

+4
source share
1 answer

Nested fragments can help solve your problem, I tried this implementation. But do not add child activity (intent) to TabHost TabSpec. All child actions must be replaced by fragments. But in my version, I do not think this implementation is good. Since navigation will be slightly related to Android, you have a return key. And pressing the return key usually returns the user to the previous screen. But this tab will ruin the reverse navigation.

+1
source

Source: https://habr.com/ru/post/1446335/


All Articles