I have an app with 3 tabs. For two of theese tabs I have buttons where I change the current fragment with a new one with this code:
MapFragment newFragment = new JourneyMapFragment(mContext, getFromDestinationCoordinate(), getToDestinationCoordinate());
android.app.FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.setCustomAnimations(android.R.animator.fade_in,
android.R.animator.fade_out);
// Replace whatever is in the fragment_container view with this fragment,
// and add the transaction to the back stack
transaction.replace(R.id.fragment_container, newFragment);
transaction.addToBackStack(null);
if(newFragment.isHidden()){
transaction.show(newFragment);
}
transaction.commit();
For on of the tabs which is a normal fragment, changing into a map fragment the back button takes me back to the original fragment with no issuse.
However, another tab which is a mapfragment, changing into a normal fragment does not give me the same action when pressing the back button. When it's pressed it changes the view to a white/black view.
This is the transaction code within the tab where the back button won't work:
Fragment newFragment = new CloseBusStopFragment(mContext, busStopList, getMyPosition());
android.app.FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.setCustomAnimations(android.R.animator.fade_in,
android.R.animator.fade_out);
// Replace whatever is in the fragment_container view with this fragment,
// and add the transaction to the back stack
transaction.replace(R.id.fragment_container, newFragment);
transaction.addToBackStack(null);
if(newFragment.isHidden()){
transaction.show(newFragment);
}
// Commit the transaction
transaction.commit();
Anyone know why this happens? Any help?