Android是否可以有多个导航图文件?
所以我使用的是Jetpack导航,碎片的数量不断增加 我们可以在不同的导航图中分离片段,如本文所述 然后我尝试将不同的导航图放在不同的文件中,因为这让我觉得文件更有条理和可读性,但当我尝试导航到不同的导航图文件时,我遇到了以下错误 nav_graph_start.xmlAndroid是否可以有多个导航图文件?,android,kotlin,android-jetpack,android-jetpack-navigation,Android,Kotlin,Android Jetpack,Android Jetpack Navigation,所以我使用的是Jetpack导航,碎片的数量不断增加 我们可以在不同的导航图中分离片段,如本文所述 然后我尝试将不同的导航图放在不同的文件中,因为这让我觉得文件更有条理和可读性,但当我尝试导航到不同的导航图文件时,我遇到了以下错误 nav_graph_start.xml <navigation xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.co
<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\u graph\u home
引用自action com.app.android:id/action\u splash\u to\u home
此导航控制器未知
所以
是否还不支持多个导航图文件
我是否遗漏了一些应该更改的内容?首先,您可以使用include。看一看 示例:first_graph.xml
<include app:graph="@navigation/second_graph" />
然后将操作设置为包含图形的id
<action
android:id="@+id/action_fragment_to_second_graph"
app:destination="@id/second_graph" />
您还可以使用扩展来使用多个合并的图
看看
实际上,每个活动都应该有自己的导航图。@narekharapetyan关于使用多个图的扩展,您在该示例中指的是什么merged@w3bshark你可以在这里找到更多细节