Android – keep clips?

Hi, I have a question about keeping fragments when recreating an activity. I heard that one way is to use setretainfragment (true) in the oncreate method. The question is - how is this different from tracking the private fragment property in an activity so that I always have the same fragment object throughout the life cycle of the activity? thank you!

@R_ 419_ 1911@:

Setretaininstance (true): the state of the fragment will be preserved (not destroyed) between configuration changes (such as screen rotation!). The state will be preserved even if the configuration change causes the "parent" activity to be destroyed. However, the view of the fragment is destroyed!

Lifecycle phone:

Setretaininstance (false): the fragment state will not be retained in configuration changes (default value)

Lifecycle phone:

Important: setretaininstance (true) is not applicable to fragments on the back-end stack. Setretaininstance (true) is particularly useful for long-running operations. Internal fragments do not care about configuration changes

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>