最近我遇到了我在这里问过的问题
但是当试图弄清楚发生了什么时,我总是偶然发现同样的问题。
这就是我所拥有的——我有一个集合、预览、编辑片段,而不是我需要在它们之间导航。
但是在从编辑片段导航到预览片段之后,我希望后退按钮将用户带到集合片段而不是编辑片段,并且它会这样做,但是当尝试进一步导航时它会崩溃,因为据说目的地是(view_fragment)。为什么会这样,是某种错误吗?
<fragment android:id="@+id/collection_fragment">
<action
android:id="@+id/action_collection_fragment_to_view_fragment"
app:destination="@+id/view_fragment" />
</fragment>
<fragment android:id="@+id/view_fragment">
<action
android:id="@+id/action_view_fragment_to_edit_fragment"
app:destination="@id/edit_fragment" />
<argument android:name="item" />
</fragment>
<fragment android:id="@+id/edit_fragment">
<action
android:id="@+id/action_edit_fragment_to_view_fragment"
app:destination="@id/view_fragment"
app:popUpTo="@id/collection_fragment" />
<argument android:name="item" />
</fragment>
编辑:
堆栈跟踪:
java.lang.IllegalArgumentException: navigation destination com.domain.application:id/action_collection_fragment_to_view_fragment is unknown to this NavController
at androidx.navigation.NavController.navigate(NavController.java:669)
at androidx.navigation.NavController.navigate(NavController.java:628)
at com.domain.application.CollectionFragment$onActivityCreated$4.onChanged(CollectionFragment.kt:126)
at com.domain.application.CollectionFragment$onActivityCreated$4.onChanged(CollectionFragment.kt:28)
at com.domain.application.common.SingleLiveEvent$observe$1.onChanged(SingleLiveEvent.kt:20)
at android.arch.lifecycle.LiveData.considerNotify(LiveData.java:109)
at android.arch.lifecycle.LiveData.dispatchingValue(LiveData.java:126)
at android.arch.lifecycle.LiveData.setValue(LiveData.java:282)
at android.arch.lifecycle.MutableLiveData.setValue(MutableLiveData.java:33)
at com.domain.application.common.SingleLiveEvent.setValue(SingleLiveEvent.kt:27)
at android.arch.lifecycle.LiveData$1.run(LiveData.java:87)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6938)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)