【发布时间】:2020-08-24 15:24:54
【问题描述】:
我正在阅读IllegalArgumentException: navigation destination xxx is unknown to this NavController 中的所有答案,但没有运气。当通过手动 recreate() 调用或从进程死亡中恢复活动重新创建活动时,我会得到这个。
我有一个Activity,它使用Navigation 更改了它的Fragments。
Fragment A 有一个 FAB,点击后会导航到 Fragment B。
floatingActionButton = view.findViewById<FloatingActionButton>(R.id.floating_action_button).apply {
setOnClickListener {
findNavController().navigate(R.id.action_fragmentA_to_fragmentB,
null,
null,
FragmentNavigatorExtras(this to "shared_element_container"))
}
}
工作正常,但是在重新创建活动后单击 FAB 时,我会崩溃。
【问题讨论】:
标签: android android-fragments illegalargumentexception android-architecture-navigation android-navigation