我使用了Jetpack navigation,但是碎片的数量不断增加。
如文档所述,我们可以将不同的碎片分为不同的导航图。
然后我尝试将不同的导航图放在不同的文件中,因为这样更有组织性和可读性。但是当我尝试导航到不同的nav_graph文件时,我遇到了以下错误。
nav_graph_start.xml
<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/nav_graph_start"
app:startDestination="@id/splashScreen"
tools:ignore="UnusedNavigation">
<fragment
android:id="@+id/splashScreen"
android:name="com.timetoface.android.splash.SplashFragment"
android:label="Login Fragment"
tools:layout="@layout/fragment_splash">
<action
android:id="@+id/action_splash_to_login"
app:destination="@id/nav_graph_auth"
/>
<action
android:id="@+id/action_splash_to_home"
app:destination="@id/nav_graph_home"
/>
</fragment>
</navigation>
nav_graph_auth.xml
<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/nav_graph_auth"
app:startDestination="@id/emailLoginScreen"
tools:ignore="UnusedNavigation">
................................
</navigation>
nav_graph_home.xml
<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/nav_graph_home"
app:startDestination="@id/emailLoginScreen"
tools:ignore="UnusedNavigation">
................................
</navigation>
导航目标com.app.android:id/nav_graph_home在从动作com.app.android:id/action_splash_to_home引用时,对于此NavController是未知的。
所以,
多个导航图文件还不支持吗?
我是否错过了应该更改的东西?