无法使用导航组件从嵌套图片段移动到主图片段

5ssjco0h  于 2021-09-13  发布在  Java
关注(0)|答案(0)|浏览(229)

我在主导航图中使用嵌套片段作为底部导航视图,但当尝试从嵌套图中的片段导航到主导航图中的登录片段时,控制器会将我重定向到homefragment,homefragment是嵌套图的startdestination
这是我的导航图xml

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <navigation xmlns:android="http://schemas.android.com/apk/res/android"
  3. xmlns:app="http://schemas.android.com/apk/res-auto"
  4. xmlns:tools="http://schemas.android.com/tools"
  5. android:id="@+id/nav_main"
  6. app:startDestination="@id/splashFragment">
  7. <fragment
  8. android:id="@+id/splashFragment"
  9. android:name="package.splash.SplashFragment"
  10. android:label="fragment_splash"
  11. tools:layout="@layout/fragment_splash">
  12. <action
  13. android:id="@+id/actionGoToHomeFromSplash"
  14. app:destination="@id/nav_home"
  15. app:launchSingleTop="true"
  16. app:popUpTo="@id/splashFragment"
  17. app:popUpToInclusive="true" />
  18. <action
  19. android:id="@+id/actionGoToLogin"
  20. app:destination="@id/loginFragment"
  21. app:launchSingleTop="true"
  22. app:popUpTo="@id/splashFragment"
  23. app:popUpToInclusive="true" />
  24. </fragment>
  25. <fragment
  26. android:id="@+id/loginFragment"
  27. android:name="package.signinup.LoginFragment"
  28. android:label="fragment_login"
  29. tools:layout="@layout/fragment_login">
  30. <action
  31. android:id="@+id/actionGoToHomeFromLogin"
  32. app:destination="@id/nav_home"
  33. app:launchSingleTop="true"
  34. app:popUpTo="@id/loginFragment"
  35. app:popUpToInclusive="true" />
  36. </fragment>
  37. <navigation
  38. android:id="@+id/nav_home"
  39. app:startDestination="@id/homeFragment">
  40. <fragment
  41. android:id="@+id/homeFragment"
  42. android:name="package.main.HomeFragment"
  43. android:label="fragment_home"
  44. tools:layout="@layout/fragment_home" />
  45. <fragment
  46. android:id="@+id/ordersFragment"
  47. android:name="package.main.OrdersFragment"
  48. android:label="fragment_orders"
  49. tools:layout="@layout/fragment_orders" />
  50. <fragment
  51. android:id="@+id/settingFragment"
  52. android:name="package.main.SettingFragment"
  53. android:label="fragment_setting"
  54. tools:layout="@layout/fragment_setting">
  55. <action
  56. android:id="@+id/actionGoToLoginFromSetting"
  57. app:destination="@id/loginFragment"
  58. />
  59. </fragment>
  60. <action
  61. android:id="@+id/actionGoToLoginFromNavChild"
  62. app:destination="@id/loginFragment"
  63. />
  64. </navigation>
  65. </navigation>

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题