Android Replace Fragment within a Fragment

前端 未结 1 658
星月不相逢
星月不相逢 2021-02-01 07:43

I have a Fragment called \"MeinProfilFragment\". And a MainActivity which handles the ActionBar-Tabs logic.

In the \"MeinProfilFragment\" i hav

1条回答
  •  不思量自难忘°
    2021-02-01 07:49

    you can replace fragment by using this

    FragmentManager fragmentManager2 = getFragmentManager();
    FragmentTransaction fragmentTransaction2 = fragmentManager2.beginTransaction();
    DetailFragment fragment2 = new DetailFragment();
    fragmentTransaction2.addToBackStack("xyz");
    fragmentTransaction2.hide(MeinProfilFragment.this);
    fragmentTransaction2.add(android.R.id.content, fragment2);
    fragmentTransaction2.commit();
    

    0 讨论(0)
提交回复
热议问题