SavedInstanceState is always null in fragment

后端 未结 5 1878
隐瞒了意图╮
隐瞒了意图╮ 2020-11-30 04:08

I have a fragment attached to the activity using XML (and setContentView() in activity). A have a problem because I have very dynamic views in my fragment, so when orientati

5条回答
  •  广开言路
    2020-11-30 04:39

    All the problem was in that I don't declare android:id for the fragment in XML. Android needs ID or TAG to recognize stored fragment and reproduce all elements in it. So guys, remember - every instance of fragment needs unique id or tag!

    Also, when setRetainInstance(true) is declared then bundle should always return null.

提交回复
热议问题