Saving Fragment State on Orientation Change

后端 未结 3 1868
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-31 20:22

I\'m creating a file manager app for Android, and two classes below are the majority of the logic that goes into doing that. What I\'m doing is that on startup of the Conten

3条回答
  •  忘掉有多难
    2020-12-31 20:56

    Just posting this since this is a major concerns faced in both work and interviews :) Before API 13 we were using onRetainNonConfigurationInstance() which is deprecated (This method was relate to Activity which is now moved in to fragment)and now we have a new method know as setRetainInstance() (method part of fragment class)this will save the state of fragments even after the activity creation.

提交回复
热议问题