本文介绍了Android导航库深层链接:如何综合回栈的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

使用 Android体系结构的导航组件,我有以下内容导航图

Using Android Architecture's Navigation component, I have the following navigation graph

->[首页]->[文章列表]->[特定文章]

我也有一个指向 [Specific Article] 的深层链接.打开后,当前导航至 [Home] .

I also have a deeplink to [Specific Article]. When it is opened, navigating up currently goes to [Home].

我想合成一个后置堆栈,以便向上导航返回 [Articles List] (然后再次导航至 [Home] ).

I'd like to synthesise a backstack such that navigating up instead goes back to [Articles List] (and then on to [Home] if navigating again).

导航的方式是什么?

推荐答案

每个 NavDeepLinkBuilder文档,导航将目标的 startDestination 用于合成后备堆栈.如果您将目标分组为嵌套的导航图,则两者嵌套图的 startDestination 和根图的 startDestination 被添加到后堆栈中.这使您能够将 [Articles List] 作为嵌套图的 startDestination ,以将其添加到后退堆栈中.

Per the NavDeepLinkBuilder documentation, Navigation uses the startDestination of the destination for the synthetic back stack. If you Group destinations into a nested navigation graph, both the startDestination of the nested graph and the startDestination of the root graph are added to the back stack. This gives you the ability to have [Articles List] as the startDestination of the nested graph to add it to your back stack.

但是,强烈建议您将合成后背堆放得尽可能小-尽管深度为2或3(如此处所示)很好,但不建议超出此范围级别,以避免用户不得不反复轻击并单击后退"按钮以返回启动器的情况.

However, it is strongly recommended to keep your synthetic back stack as small as possible - while a depth of 2 or 3 (as here) is fine, it is not recommended to go much beyond that level to avoid cases where users have to repeatedly tap and tap the back button to get back to the launcher.

这篇关于Android导航库深层链接:如何综合回栈的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 18:59