FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.replace(R.id.container, fragment); transaction.addToBackStack("NameOfFragment"); transaction.commit();