Retain the Fragment object while rotating

后端 未结 6 1256
滥情空心
滥情空心 2020-12-01 00:18

I have developed an app in Honeycomb and I am using fragments.
This is my app

  • I have an Activity (Say A1) and in that there is a fragment
  • Initi
6条回答
  •  Happy的楠姐
    2020-12-01 00:27

    I defined a Fragment in activity's layout, onSaveInstanceState in the Fragment does get called, but the savedInstanceState Bundle in the Fragment's onCreatView comes as null.

    The reason was that my Fragment did not have a ID in XML:

    android:id="@+id/compass_fragment" ...
    

提交回复
热议问题