pop specific fragment from stack and remove others

前端 未结 5 1025
情话喂你
情话喂你 2020-12-30 07:32

how I can pop specific fragment from stack and remove others from a fragment? for example these are my fragments and I\'m in E right know.

A-> B -> C -> D ->E

<
5条回答
  •  醉梦人生
    2020-12-30 08:22

    Use following code for pop back stack entry:

     FragmentManager fm = getSupportFragmentManager();
    
        if (fm.getBackStackEntryCount() > 0) {
    
            fm.popBackStack();
    
        }else {
            super.onBackPressed();
        }
    

提交回复
热议问题