Android Can't retain fragments that are nested in other fragments

前端 未结 1 1420
无人及你
无人及你 2021-02-05 16:26

there is sth wrong with my Application,I try to add three Fragments in another Fragment,then the Eclipse show this:

java.lang.IllegalSt

1条回答
  •  伪装坚强ぢ
    2021-02-05 16:45

    Can't retain fragements that are nested in other fragments

    This is a limitation of nested Fragments. I'm guessing one or more of your child Fragments have setRetainInstance(true) somewhere in their code. You need to remove that to prevent the error.

    EDIT: On further reading it seems if the parent Fragment is calling setRetainInstance(true) then it will cause the same exception due to the fact that attempting to retain the parent instance also attempts to retain the child Fragments.

    0 讨论(0)
提交回复
热议问题