Can't retain nested fragments

后端 未结 4 497
星月不相逢
星月不相逢 2020-12-24 08:42

Is there another way of saving the state of the nested fragment ? Or if we shouldn\'t do this, why ? Thanks !

02-13 11:42:43.258: E/AndroidRuntime(7167): ja         


        
4条回答
  •  南笙
    南笙 (楼主)
    2020-12-24 09:24

    You can use FragmentManager.saveFragmentInstanceState(Fragment) to retrieve a fragment state. The return value implements Parcelable, so you can put it in a Bundle.

    For restoration, you can provide the state after creating the fragment using Fragment.setInitialSavedState(Fragment.SavedState).

提交回复
热议问题