我有一个片段 A、B、C。从 A -> B 导航时没问题,但从 B -> C 时它崩溃了。
这是我的导航
这是我的导航代码
categoryProductItemListAdapter.setOnItemClickListener {
val action = CategoryProductItemsDirections.actionCategoryProductItems2ToProductItem(null, it)
navController = Navigation.findNavController(requireView())
navController?.navigateUp()
navController?.navigate(action)
}
Run Code Online (Sandbox Code Playgroud)
这是 productItem 目的地的 XML 代码
<fragment
android:id="@+id/categoryProductItems2"
android:name="com.sample.store.main.dashboard.ui.ui.home.categoryitems.CategoryProductItems"
android:label="CategoryProductItems"
tools:layout="@layout/fragment_category_product_items">
<argument
android:name="category_global"
app:argType="com.sample.store.data.globalmodels.response.categories.Category" />
<action
android:id="@+id/action_categoryProductItems2_to_productItem"
app:destination="@id/productItem"
app:enterAnim="@anim/enter_from_right"
app:exitAnim="@anim/exit_to_right"
app:popEnterAnim="@anim/fragment_open_enter"
app:popExitAnim="@anim/fragment_fade_exit" />
</fragment>
Run Code Online (Sandbox Code Playgroud)
这是错误:
java.lang.IllegalArgumentException: Navigation action/destination com.sample.store.full:id/action_categoryProductItems2_to_productItem cannot be found from the current destination Destination(id/navigation_home) label=Home class=com.sample.store.main.dashboard.ui.ui.home.mainui.HomeFragment
Run Code Online (Sandbox Code Playgroud)
我不知道发生了什么,但似乎 navController 正在寻找“navigation_home”