savedInstanceState when restoring fragment from back stack

后端 未结 4 432
礼貌的吻别
礼貌的吻别 2021-01-31 15:53

Can I use savedInstanceState() to save the state when removing a fragment, then restore the state when I pop the fragment off the back stack? When I restore the fr

4条回答
  •  别那么骄傲
    2021-01-31 15:57

    I like to store the View I return in onCreateView as a global variable and then when I return I simply check this:

    if(mBaseView != null) {
            // Remove the view from the parent
            ((ViewGroup)mBaseView.getParent()).removeView(mBaseView);
            // Return it
            return mBaseView;
        }
    

提交回复
热议问题