如何摧毁片段? [英] How to destroy Fragment?

查看:132
本文介绍了如何摧毁片段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个活动。该活动有两个片段秒。 片段A是菜单。片段B是详细信息。

I have one Activity. The Activity has two Fragments. Fragment A is Menu. Fragment B is Detail.

我尽量让其他C片段的片段B,所以,有3个片段在活动。 我试图取代片段B到D片段。

I try to Make other Fragment C in Fragment B, so, There are 3 Fragment in the Activity. And I try to Replace Fragment B to Fragment D.

我猜片段B和C是死的。 但这些碎片是活的。只是片段 onDestroyView()状态。我想的onDestroy() onDetach()

I guess Fragment B and C is dead. BUT these Fragments is alive. Just Fragments are onDestroyView() state. I want onDestroy() or onDetach().

我该怎么办了 Fragments.onDestroy() onDetach()?我不能破坏或改变活动

What do I do for Fragments.onDestroy() or onDetach()? I can't destroy or change the Activity.

推荐答案

如果您不手动删除这些碎片,它们仍然会附加到活动中。你的活动不被破坏等等这些片段也有同感。 要删除(这样破坏)这些片段,您可以拨打:

If you don't remove manually these fragments, they are still attached to the activity. Your activity is not destroyed so these fragments are too. To remove (so destroy) these fragments, you can call:

fragmentTransaction.remove(yourfragment).commit()

希望它可以帮助你。

Hope it helps to you

这篇关于如何摧毁片段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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