Android Navigation Drawer Fragment State

后端 未结 4 1963
北海茫月
北海茫月 2020-12-14 20:56

I\'m currently utilizing the Navigation Drawer for my Android APP. In my first fragment, I\'ve a fragment that loads data using Facebook\'s Graph API. Thus, when my App is f

4条回答
  •  情歌与酒
    2020-12-14 21:03

    In case someone want's a different approach to this: you could find the fragment on the stack:

    // check if this fragment is on the backstack to avoid creating a new one
        Fragment foundFragment =  fragmentManager.findFragmentByTag("unique_fragment_tag");
        if (foundFragment != null) {
              fragmentManager.popBackStackImmediate("unique_fragment_tag", 0);
                return;
        }
    

提交回复
热议问题