Android 4.2: back stack behaviour with nested fragments

后端 未结 17 1792
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-29 16:01

With Android 4.2, the support library got support for nested fragments see here. I\'ve played around with it and found an interesting behaviour / bug regarding back stack an

17条回答
  •  失恋的感觉
    2020-11-29 16:36

    for ChildFragments this works..

    @Override
        public void onBackPressed() {
    
     if (getSupportFragmentManager().getBackStackEntryCount() > 0) {
                getSupportFragmentManager().popBackStack();
            } else {
                doExit(); //super.onBackPressed();
            }
    }
    

提交回复
热议问题