gpt4 book ai didi

android - 如何在导航组件中从 Dialog 导航到 Fragment?

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

我试图在导航组件中从 DialogFragment 导航到 Fragment,但结果很奇怪。

enter image description here

当我从 DialogFragment 导航到 Fragment 时,背景 fragment 正在更改为目标 fragment ,当前对话框位于其顶部,而不是仅仅移动到目标 fragment 。

这是导航图。

<navigation
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/home"
app:startDestination="@+id/titleScreen">

<fragment
android:id="@+id/titleScreen"
android:name="com.example.android.navigationadvancedsample.homescreen.Title"
android:label="@string/title_home"
tools:layout="@layout/fragment_title">
<action
android:id="@+id/action_title_to_about"
app:destination="@id/aboutScreen"/>
</fragment>
<dialog
android:id="@+id/aboutScreen"
android:name="com.example.android.navigationadvancedsample.homescreen.About"
android:label="@string/title_about"
tools:layout="@layout/fragment_about">
<action
android:id="@+id/action_aboutScreen_to_register"
app:destination="@id/register" />
</dialog>
<fragment
android:id="@+id/register"
android:name="com.example.android.navigationadvancedsample.formscreen.Register"
android:label="fragment_leaderboard"
tools:layout="@layout/fragment_leaderboard" />
</navigation>

为什么我会出现这种行为或如何解决?

我所说的修复是指正常的对话行为。比如说,我在 fragment A 的顶部有一个对话框 D 并从 D B strong>,屏幕应显示 B。当我从 B 弹出时,它应该转到 A 之上的 D 的前一阶段。

最佳答案

感谢@musooff 提交 this bug

此问题已在 Navigation 2.1.0-alpha06 以及其他对话框不一致问题(如 back button when Dialog is popped)上得到修复.

但是,如果可以,请更新到 2.1.0-beta02 或更高版本。

关于android - 如何在导航组件中从 Dialog 导航到 Fragment?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56387979/

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