fragments and onConfigurationChanged

前端 未结 5 689
清歌不尽
清歌不尽 2021-02-06 07:00

I\'m trying to do something I do with activities, but within a fragment. What I do is using activities:

First stop the activity restarts when rotating the device a

5条回答
  •  别那么骄傲
    2021-02-06 07:58

    Have you considered retaining your fragment instances? See Fragment#setRetainInstance.

    Allow your Activity to be recreated (do not specify android:configChanges) but retain your fragment instances across orientation changes. If all the heavy lifting happens in Fragment#onCreate this should work fine. onCreate() will not be called again since the fragment is not being re-created.

提交回复
热议问题