Unable to replace/navigate fragments

前端 未结 2 2064
深忆病人
深忆病人 2020-12-18 09:50

I am trying to navigate from one fragment to another. These two fragments are 100% different, there is no ViewPager or something like that to connect them. Here

2条回答
  •  醉话见心
    2020-12-18 10:39

    You are trying to replace firstView with the new fragment, but firstView is not a fragment, its' a RelativeLayout.

    You cannot replace a fragment defined statically in the layout file. You can only replace fragments that you added dynamically via a FragmentTransaction.

    None of your Layout contains fragment in layout.

    
    

    A new Fragment will replace an existing Fragment that was previously added to the container.

    Take look on this.

提交回复
热议问题