Tucao
I used a stack to manage multiple Fragment jumps. Now I found everything is so simple, ah, face to face ....
The add, remove, and replace operations on Fragment are all performed through the FragmentTransaction transaction. After beginTransaction
Execute a series of Fragment operations. Before committing, if you use the addToBackStack function, you can save the transaction operation in the stack. So that when you press
When the back button is used, it can restore the transaction operation so that the interface returns to the status before this transaction. The result is equivalent to returning the previous Activity.
This article implements multi-layer jump and return of the tab framework.
replaceTabView( containerViewID, Fragment frag, String tag, = =
In actual use, we often need to switch the view on the current tab. For example, you can click a news item in the list on the News tab to go to the details page. Therefore, it is much easier to add the following functions to replace the current interface.
(MTabHost is your TabHost instance ):
During the simulation, I added a jump button to a Fragment to jump to the second Fragment. Here I use FirstPageFragment
Jump to SecondFloorFragment.
SecondFloorFragment(), "second"
Now, by adding the above code, you can jump to SecondFloorFragment in FirstPageFragment, and when you press the return key, you can return to FirstPageFragment.