如何findFragmentByTag是在其他活动产生的? [英] How to findFragmentByTag that is created in another Activity?

查看:76
本文介绍了如何findFragmentByTag是在其他活动产生的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要找到一个由可破坏其他活动创建一个片段。然而,似乎是,当活动被破坏,该片段堆栈丢失以及

I need to find a fragment that was created by another activity that may be destroyed. However, it seems that when the activity is destroyed, the fragment stack is lost as well.

是否有可能保存在另一个活动创建的片段?然后重新使用这些片段?

Is it possible to save the fragments created in another activity? Then re-use those fragments?

我的用例是,我开始在活动包含片段,然后启动含B,C,D,E碎片B的活性。假如我回去,并返回,在这个过程中破坏B活性。难道还要为B的活性找到B,C,D,E碎片?

My use case is that I start at activity A containing A fragment, then it launches B activity containing B, C, D, E fragments. Suppose I go back and return, destroying B activity in the process. Is it still possible for B activity to find B, C, D, E fragments?

推荐答案

片段的生命周期是其活性生命周期的同步,例如,当活动进入停止状态,片段到停止状态,也是如此。如果你想在你的活动使用的片段,则需要再次膨胀了。

Fragment lifecycle is sync with its activity life cycle, for example, when activity enters stop state, fragment goes to stop state as well. If you want to use a fragment in your activity, you need to inflate it again.

http://developer.android.com/reference/android/app/ Fragment.html

一个片段的生命周期绑定到其所属的活动,它有自己的
  对标活动周期皱纹

a Fragment's lifecycle is tied to its owning activity, it has its own wrinkle on the standard activity lifecycle

这篇关于如何findFragmentByTag是在其他活动产生的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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