Fragments: Remove all fragments in a view

后端 未结 5 749
终归单人心
终归单人心 2020-12-16 17:25

The scenario I am faced with, is in my application I have a single pane and dual pane style layout. Rather than individually handle every single navigation

5条回答
  •  自闭症患者
    2020-12-16 18:05

    If you use android.support.v4.app.Fragment you can do this:

    List fragments = getSupportFragmentManager().getFragments();
    if (fragments != null) {
        for (Fragment fragment : fragments) {
            getSupportFragmentManager().beginTransaction().remove(fragment).commit();
        }
    }
    

提交回复
热议问题