保留活动的碎片状态 [英] Retain Fragment state between Activities

查看:127
本文介绍了保留活动的碎片状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

它能够保持一个片段活动的?

可以说我有活动 A 与片段 F_Left 放置在左侧和片段 F_Right 放置在右侧。如果我想推出一个新的活动,并保持片段 F_Left ......我该怎么办呢?

我可以保留片段 F_Left 活动之间的状态?

请注意,我想推出一个新的活动,因为片段 F_Left 是我的应用程序菜单和片段 F_Right 完全改变用户操作的情况下... ...和我的应用程序有很多的操作,因此是很有意义让每个操作的活动。

我知道它可以保留片段活动之内,但为片段的生命周期是密切联系在一起的容器活动我不知道这是否可能保持片段活动之间的状态。

解决方案
  

如果我想推出一个新的活动,并保持片段F_Left ......我该怎么办呢?

不要推出新的活动。

  

我可以保留活动之间的片段F_Left状态?

不自动。它是不一样的片段。你会传递活动之间数据的片段不使用不同于你将没有任何碎片都没有。

Its possible to retain a Fragment between Activities?

Lets say I have Activity A with Fragment F_Left placed at the left and Fragment F_Right placed at the right. If I want to launch a new Activity and keep Fragment F_Left... how can I do it?

Can I retain Fragment F_Left state between activities?

Note that I want to launch a new Activity because Fragment F_Left is my app menu and Fragment F_Right changes completely the context of the user operations... and my app have many of operations, so it makes sense to have an Activity per operation.

I know its possible to retain Fragment within an Activity, but as Fragment life cycle is closely tied to the container Activity I don't know if this is possible keep Fragment state between Activities.

解决方案

If I want to launch a new Activity and keep Fragment F_Left... how can I do it?

Don't launch a new activity.

Can I retain Fragment F_Left state between activities?

Not automatically. It is not the same fragment. You would pass data between the activities for use by the fragment no differently than you would without any fragments at all.

这篇关于保留活动的碎片状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆