我有三个片段Fragment1 -> Fragment3 -> Fragment4,所以如果我单击Fragment4中的后退按钮,我需要使用导航组件转到Fragment1popUpto
,我看到了,但我不明白。
你能告诉我我做错了什么吗?
我已经使用popUpTo
了财产,但这不起作用
<?xml version="1.0" encoding="utf-8"?>
<navigation
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/navigation_graph"
app:startDestination="@id/first_fragment">
<fragment
android:id="@+id/first_fragment"
android:name="com.example.navbottom.ui.navScreen.fragments.FirstFragment"
android:label="first_fragment"
tools:layout="@layout/fragment_first">
<action
android:id="@+id/action_first_fragment_to_third_fragment"
app:destination="@id/third_fragment" />
</fragment>
<fragment
android:id="@+id/third_fragment"
android:name="com.example.navbottom.ui.navScreen.fragments.ThirdFragment"
android:label="Third_Fragment"
tools:layout="@layout/fragment_third" >
<action
android:id="@+id/action_third_fragment_to_fourth_fragment"
app:destination="@id/fourth_fragment" />
</fragment>
<fragment
android:id="@+id/fourth_fragment"
android:name="com.example.navbottom.ui.navScreen.fragments.FourthFragment"
android:label="fragment_fourth"
tools:layout="@layout/fragment_fourth" >
<action
android:id="@+id/action_fourth_fragment_to_first_fragment"
app:destination="@id/first_fragment"
app:popUpTo="@id/fourth_fragment"
app:popUpToInclusive="false"/>
</fragment>
</navigation>
没有任何反应,它会进入Fragment4 -> Fragment3 -> Fragment1