Getting a reference to a child Fragment after the parent Fragment has been recreated

前端 未结 3 1268
有刺的猬
有刺的猬 2021-01-31 19:13

Starting Android 4.2, Android supports nested Fragments. The doc doesn\'t give a lot of explanations regarding nested Fragment lifecycles but from experience, it ap

3条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-31 19:50

    What about setRetainInstanceState(true) on your fragment? Could it solve your problem? It solved some problems when I have ChildFragments in a Fragment. I only have to keep a reference to the childfragment in the fragment.

    But I allways did that in onCreateView(). Not sure if it will work in onCreate()

    Or do you mean something completely different?

提交回复
热议问题