简体   繁体   English

是否有片段的任何启动模式,例如“活动”启动模式?

[英]Is there any launch modes for fragments like Activity launch modes?

My Problem: 我的问题:

* * * *

A ->Main Fragment where everything starts and ends, a list fragment A-> Main Fragment,所有内容的开始和结束,一个list片段

B ->Fragment that provides location selection from drop down and button to select location from map. B->片段,可从下拉菜单中选择位置,并提供按钮从地图中选择位置。

C ->Fragment that used for location selection from map C->用于从地图中选择位置的片​​段

D ->Fragment that is used to Edit/Add item in the List D->用于编辑/添加列表中项目的片段

The Normal flows of my functionality is 我功能的正常流程是

  1. Main->A->B->C->D->A (Flow of adding location to the list from map) Main-> A-> B-> C-> D-> A(将位置从地图添加到列表的流程)
  2. Main->A->B->D->A (Flow of adding location to the list from drop down) Main-> A-> B-> D-> A(从下拉列表添加位置到列表的流程)
  3. Main->A->D->B->D->A (Flow of Editing list) Main-> A-> D-> B-> D-> A(编辑列表流程)

My Doubt is the fragment B can be loaded before fragment D and after fragment D, So when i load fragment B , 我的怀疑是片段B可以在片段D之前和之后加载,所以当我加载片段B时,

  1. i want to check whether there is already an instance and i want to reuse it 我想检查是否已经有一个实例,我想重用它
  2. other case remove the old instance and reload new. 在其他情况下,请删除旧实例并重新加载新实例。

How its done in case of fragment. 碎片情况下如何完成。 In Activity we use launch modes for that. 在活动中,我们为此使用启动模式。

Thanks in Advance. 提前致谢。

FragmentManager allows you to retrieve Fragments from the back stack: FragmentManager允许您从后堆栈中检索片段:

findFragmentById(int) findFragmentById(INT)

findFragmentByTag(String) findFragmentByTag(字符串)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM