Removing fragments from an activity

后端 未结 4 1353
陌清茗
陌清茗 2021-01-30 20:54
FragmantClass rSum = new FragmantClass();
getSupportFragmentManager().beginTransaction().remove(rSum).commit();       

I am trying to remove this fragm

4条回答
  •  遥遥无期
    2021-01-30 21:44

    getSupportFragmentManager().beginTransaction().
    remove(getSupportFragmentManager().findFragmentById(R.id.frame)).commit();
    

    Try this, it should work.

    public void switchContent(Fragment fragment) {
        getSupportFragmentManager().beginTransaction().
        remove(getSupportFragmentManager().findFragmentById(R.id.frame)).commit();
        mContent = fragment;
        getSupportFragmentManager()
            .beginTransaction()
            .replace(R.id.content_frame, fragment)
            .commit();
        getSlidingMenu().showContent();
    }
    

提交回复
热议问题