Replacing a fragment does not replace the previous fragment entirely. Why so?

后端 未结 1 379
青春惊慌失措
青春惊慌失措 2021-01-21 19:50

I\'m implementing a \"fragments-101\" program, where-in I replace a fragment when its corresponding button is clicked. However, the below thing happens:

1条回答
  •  长发绾君心
    2021-01-21 20:37

    Fragments that are inflated directly from xml layout with tag cannot be replaced.

    You should have an empty FrameLayout inside your xml layout. And you should add, remove, replace all your Fragments programmatically into that FrameLayout.

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