I have a list which when clicking on an item shows me the detail in a fragment, and I have a button that allows me to add records, both load in the same container, the problem is generated when I start to open several items already the time I open the fragment to add records.
When I go back everything works fine, but I would like to return to the last fragment stack that I have intervened, because my data overlap, I leave my code and image of how it looks.
Code
//Usado al mostrar un detallle
FragDetalle fragDetalle = new FragDetalle();
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(R.id.fl_contenedor_lateral, fragDetalle);
ft.addToBackStack(null);
ft.commit();
//Usado en el botón nuevo
FragNuevo fragNuevo = new FragNuevo();
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(R.id.fl_contenedor_lateral, fragNuevo);
ft.addToBackStack(null);
ft.commit();
Image
The problem is only generated if you interacted with the two fragments, so I would just like to go back to the last stack of addToBackStack()
, and eliminate the rest so that it does not show me the superimposed data or in any case if there is another serious solution great.