How can I use FragmentManager to display Fragment A, B, C,… in a FrameLayout?

后端 未结 1 1892
长情又很酷
长情又很酷 2020-12-10 06:13

Dear StackOverflow people,

I have currently one big issue in my Android application.

I am using Fragments for all my activities and I read all the doc here:

相关标签:
1条回答
  • 2020-12-10 06:32

    use FragmentTransaction to replace fragments.

    you can do the replace of fragments programatically.

    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    FragmentB fb = new FragmentB();
    ft.replace(R.id.list, fb);
    ft.addToBackStack("replacingFragmentA");
    ft.commit();
    

    add to back stack is optional.

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