在我的案件中,我是两度 setting子,造成了错误:
(a) 在安乐施会档案中:
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustNothing"
tools:ignore="LockedOrientationActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<nav-graph android:value="@navigation/navigation_app_graph" />
</activity>
活动一度——主轴:
<androidx.fragment.app.FragmentContainerView
android:id="@+id/nav_host_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:defaultNavHost="true"
app:layout_constraintBottom_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:navGraph="@navigation/navigation_app_graph"
tools:ignore="UnusedIds"
tools:layout="@layout/fragment_mosaic" />
活动标的内线的导航图为主要活动确定导航图。 这正是你为这一活动配置导航图的地方。
您可以删除其他定义,该定义是内部的;androidx.fragment.app.FragmentContainerView>
app:navGraph="@navigation/navigation_app_graph"
After all, the navigation graph has already been defined for the main activity, and you don t need to define it again inside the FragmentContainerView.