相关疑难解决方法(0)

使用架构组件进行多模块导航

所以我在我当前的应用程序中为我的模块设置了这个结构.

应用模块结构

我还没有找到任何有关多模块导航的官方文档,但我发现这篇文章的内容是关于这一点的,这里是我的gradle文件的方式:

特征1 - 细节

...
implementation project(":base")
implementation project(":feature-2-detail")
...
Run Code Online (Sandbox Code Playgroud)

特征2 - 细节

...
implementation project(":base")
implementation project(":feature-1-detail")
...
Run Code Online (Sandbox Code Playgroud)

特征3 - 细节

...
implementation project(":base")
implementation project(":feature-1-detail")
...
Run Code Online (Sandbox Code Playgroud)

这是我的导航图:

特征1 - 细节

<navigation ...
    android:id="@+id/graph_feature_1_id">
    <include app:graph="@navigation/graph_feature_2" />
    <fragment ...
        android:id="@+id/nav_feature_1">
        <action ...
            app:destination="@+id/graph_feature_2_id" />

    </fragment>
</navigation>
Run Code Online (Sandbox Code Playgroud)

特征2 - 细节

<navigation ...
    android:id="@+id/graph_feature_2_id">
    <include app:graph="@navigation/graph_feature_1" />
    <fragment ...
        android:id="@+id/nav_feature_2">
        <action ...
            app:destination="@+id/graph_feature_1_id" />

    </fragment>
</navigation>
Run Code Online (Sandbox Code Playgroud)

特征3 - 细节

<navigation ...
    android:id="@+id/graph_feature_3_id">
    <include app:graph="@navigation/graph_feature_1" />
    <fragment ...
        android:id="@+id/nav_feature_3"> …
Run Code Online (Sandbox Code Playgroud)

android android-architecture-components android-architecture-navigation

13
推荐指数
2
解决办法
2609
查看次数

嵌套导航图的循环参考

我有一个复杂的导航结构,我从一个导航图开始,然后根据一些逻辑,决定要转到哪个导航图。然而,两个导航图共享 3 个其他导航图。见下图

例子

目前,如果我尝试在 A 和 B 中包含每个导航图,我会收到循环引用错误。我还尝试创建一个全局操作,这会导致非法参数异常,因为它在导航图中不存在。

请帮忙!!!

navigation android fragment circular-reference illegalargumentexception

8
推荐指数
1
解决办法
449
查看次数