0
  1. I'm trying below code to replace the new fragment, but it's not Replaced.

    android.app.Fragment Manager fragmentManager = ((Activity) context). getFragmentManager(); android.app.FragmentTransaction fragmentTransaction=fragmentManager.beginTransaction(); fragmentTransaction.add(R.id.frame_container, menuItemDetailsFragment); fragmentTransaction.addToBackStack(null); fragmentTransaction.commit();

1 Answers1

1

You actually need to use the replace function Just replace this line of code

fragmentTransaction.add(R.id.frame_container, menuItemDetailsFragment); 

with this

fragmentTransaction.replace(R.id.frame_container, menuItemDetailsFragment); 
Umar Ata
  • 4,170
  • 3
  • 23
  • 35