【发布时间】:2021-05-29 13:44:01
【问题描述】:
我正在使用 Android 导航组件和单个 Activity 架构。我想将一个数据类对象从模块 A 发送到模块 B。
我的 feed 模块在 build.gradle 中导入 store_article 模块。
从我的 feed 模块到我的 store_article 模块的重定向有效。
我的 feed_nav_graph.xml 看起来像这样:
<fragment
android:id="@+id/newsDetailFragment"
android:name="news.feed.view.ui.NewsDetailFragment"
tools:layout="@layout/fragment_news_detail">
<argument
android:name="article"
app:argType="feed.model.Article" />
<action
android:id="@+id/action_newsDetailFragment_to_storedArticleScreenFragment"
app:destination="@id/storedArticleScreenFragment" />
</fragment>
<fragment
android:id="@+id/storedArticleScreenFragment"
android:name="news.stored_article.view.ui.StoredArticleScreenFragment"
android:label="Stored Articles"
tools:layout="@layout/fragment_stored_article_screen">
<argument
android:name="article"
app:argType=".core.Article" />
</fragment>
我现在如何从我的 store_article 模块访问数据类对象?
我不能这样做val args: StoredArticleScreenFragmentArgs by navArgs(),因为我必须导入 feed 模块,这会导致循环依赖错误。
class StoredArticleScreenFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
}
}
【问题讨论】:
标签: android kotlin android-architecture-navigation multi-module data-class