android – 结束片段

前端之家收集整理的这篇文章主要介绍了android – 结束片段前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
所以我要了解如何打开一个片段.这是我的困境.我有一个我的视图旁边的元素列表(周期表元素).当您选择一个元素时,它会显示它的信息.

我的问题是我需要能够从(我们称之为详细信息片段)中移除视图并将其从堆栈中删除,因为我没有大量的内存备份.

调用新片段替换它时,如何将其从堆栈中删除

解决方法

您可以使用FragmentTransaction的#remove()方法删除片段.此方法还会从已附加的容器中删除视图.

但是,从片段文档:

Stopped:
The fragment is not visible. Either the host activity has been stopped or the fragment has been removed from the activity but added to the back stack. A stopped fragment is still alive (all state and member information is retained by the system). However,it is no longer visible to the user and will be killed if the activity is killed.

如果你已经将该片段添加到后面的堆栈中,那么在活动被杀死之前它不会被杀死.

原文链接:https://www.f2er.com/android/315591.html

猜你在找的Android相关文章