I have an action with an action bar and tabs in the action bar. When I select an item from the contents of the tabs, I try to replace the current fragment with a new one, add the transaction to the back stack and hide the tabs.
I hide the tabs, changing the navigation mode of the action bar to standard.
The problem is that when I click the "Back" button, I just get an empty view with the action bar (in standard mode). The fragment operation does not appear to be reversed.
If I do not hide the tabs, changing the navigation mode to the standard, then the transaction change is fine.
I tried to override the back press to change the navigation mode to tabs, but this will not work.
Can someone tell me how they will achieve this?
Here is the code where the tabs hide and the fragment transaction occurs:
ActionBar actionBar = getActivity().getActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
Fragment albumListFragment = new AlbumListFragment();
albumListFragment.setArguments(bundle);
FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.replace(android.R.id.content, albumListFragment);
ft.addToBackStack(null);
ft.commit();
For clarity: I would expect that after this transaction is completed, the tabs will return to view with the previous snippet. At the moment, after pressing back, it does not show the tab OR fragment.
source
share