I have created 3 Fragments namely (FragmentA, FragmentB, FragmentC) and one MainActivity. There is a button in each fragment which replaces itself with next Fragment till FragmentC.
I am replacing FragmentA (with) FragmentB (then with) FragmentC.
Transaction from FragmentA to FragmentB uses below function
@Override
public void fragmentreplacewithbackstack(Fragment fragment, String tag) {
FragmentManager fragmentManager=getSupportFragmentManager();
FragmentTransaction fragmentTransaction=fragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.contner,fragment , tag);
fragmentTransaction.addToBackStack(null);
fragmentTransaction.commit();
// fragmentManager.executePendingTransactions();
}
Transaction from FragmentB to FragmentC uses below function
public void fragmentreplace(Fragment fragment,String tag){
FragmentManager fragmentManager=getSupportFragmentManager();
FragmentTransaction fragmentTransaction=fragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.contner,fragment , tag);
fragmentTransaction.commit();
}
problem is when i press back button from FragmentC, FragmentC and FragmentA overlap with each other.