gpt4 book ai didi

android - 不要使用 Android 导航组件在后台堆栈中包含 fragment

转载 作者:太空宇宙 更新时间:2023-11-03 13:40:54 25 4
gpt4 key购买 nike

我正在开发一款用户可以创建 Activity 的应用程序。我想这样做,以便在他们创建事件之后,后退按钮不会将他们带到创建流程,而是带到创建流程之前的屏幕。像这样的东西:

主屏幕 -> 创建流程 -> 事件摘要

然后,如果他们按下后退按钮,我希望它继续

事件摘要(后退按钮)主屏幕

我已经接近:

<fragment
android:id="@+id/createMeetFragment"
android:name=".CreateMeetFragment"
android:label="CreateMeetFragment" >
<action
android:id="@+id/action_createMeetFragment_to_meet_detail_graph"
app:destination="@id/meet_detail_graph"
app:popUpTo="@+id/mainFragment" />
</fragment>

这很好用,因为它会弹出到主屏幕。我还没有找到关于这些 pop 行为选项的很多文档 this .

我对这个解决方案的问题是,据我所知,它会弹出,直到我们到达主屏幕,无论用户如何创建事件。我更喜欢在创建流程之前弹出屏幕的解决方案,允许创建流程的多个入口点。

最佳答案

I'd prefer a solution that just pops to the screen before the creation flow, allowing for multiple entry points to the creation flow.

您不应弹出到主屏幕,而应弹出包含创建流程的第一个屏幕

<fragment
android:id="@+id/createMeetFragment"
android:name=".CreateMeetFragment"
android:label="CreateMeetFragment" >
<action
android:id="@+id/action_createMeetFragment_to_meet_detail_graph"
app:destination="@id/meet_detail_graph"
app:popUpTo="@+id/firstCreateFlowFragment"
app:popUpToInclusive="true" />
</fragment>

关于android - 不要使用 Android 导航组件在后台堆栈中包含 fragment ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52146807/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com