In the code you have commented, change the .show()
by
transaction.replace(R.id.id_del_fragment_del_layout, nuevoFragment);
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
As you can see the documentation , the method .show()
serves to show a Fragment
, that has been hidden by the method .hide()
of FragmentTransaction
, in your case, what you need is to replace the Fragment
, with the new Fragment
of Tab_Mapas_Fragment()
, the transition I've put that, but apart from being optional, you have in the link above, the different options.
The option of .replace()
, will serve you if you do not need to maintain the status of the previous Fragment, in case you need to keep the previous Fragment
, you should use the .remove()
and .add()
methods. That way when you change from Fragment
, and you give the back button, it will return you to the Fragment
previous in the last state that you left it.
((AppCompactActivity)context).getSupportFragmentManager()
.beginTransaction()
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE);
.remove(referencia_al_fragment_a_reemplazar)
.commit();
((AppCompactActivity)context).getSupportFragmentManager()
.beginTransaction()
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
.replace(R.id.contenedor_del_fragment, nuevoFragmento)
.commit();