使用导航架构组件添加(而不是替换)片段 [英] Add (not replace) fragment with navigation architecture component

查看:74
本文介绍了使用导航架构组件添加(而不是替换)片段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含产品列表片段和许多其他片段的活动,我正在尝试使用体系结构组件导航控制器.

I have an activity with a product list fragment and many other fragments and I am trying to use architecture component navigation controller.

问题是:它替换了(开始目标)产品列表片段,并且我不希望用户单击后退"按钮时重新加载列表.

The problem is: it replaces the (start destination) product list fragment and I don't want the list to be reloaded when user click back button.

如何使片段事务作为添加而不是替换?

How to make the fragment transaction as add not replace?

推荐答案

Android导航组件只是替换,但您想添加片段而不是像对话框那样替换,您可以使用它,但需要最小化. " 版本2.1.0 进行导航组件.

Android navigation component just replace but you want to add fragment instead of replace like dialog you can use this but need to min. "Version 2.1.0" for navigation component.

解决方案

Solution

,您会看到" 对话框目标 "

and you can see "Dialog destinations"

这篇关于使用导航架构组件添加(而不是替换)片段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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