Using onSaveInstanceState with fragments in backstack?

前端 未结 4 1397
一向
一向 2020-11-27 15:26

I have fragments I keep in the backstack of FragmentManager. Every fragment state is saved for orientation changes with member variables, like this for example:

<         


        
4条回答
  •  有刺的猬
    2020-11-27 16:14

    Building on Jorge Gil - 'xɔɾ.xɛ xil answer Note the following:

    • Don't forget call the super implementations of onSaveInstanceState() and onRestoreInstanceState().
    • If you are using the support package: Please use getSupportFragmentManager() instead of getFragmentManager().
    • When retrieving your original fragment you got to cast it.

    Sorry for being Captain obvious!

提交回复
热议问题