Android 导航片段显示在导航架构组件jetpack中前一个片段的后面

Android 导航片段显示在导航架构组件jetpack中前一个片段的后面,android,kotlin,android-fragments,android-jetpack,android-jetpack-navigation,Android,Kotlin,Android Fragments,Android Jetpack,Android Jetpack Navigation,我在一个动作上调用了`onItemSelected()方法,任何帮助都会很好。谢谢 当从餐厅列表导航到餐厅细节片段时,它是这样的。我一直受这个问题困扰这么久如何将NavHostFragment添加到布局中?听起来布局中有两个NavHostFragment实例。在onStart之前调用navigation()时,我对新片段管理器也有同样的问题。您是如何解决的@你解决了吗?是的!我已将标记替换为活动xml文件中的 <?xml version="1.0" encoding=&

我在一个动作上调用了`onItemSelected()方法,任何帮助都会很好。谢谢


当从餐厅列表导航到餐厅细节片段时,它是这样的。我一直受这个问题困扰这么久

如何将
NavHostFragment
添加到布局中?听起来布局中有两个
NavHostFragment
实例。在
onStart
之前调用
navigation()
时,我对新片段管理器也有同样的问题。您是如何解决的@你解决了吗?是的!我已将标记替换为活动xml文件中的
<?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/nav_graph"
    app:startDestination="@id/restaurantListFragment">

    <fragment
        android:id="@+id/scanQRFragment"
        android:name="com.example.dine.ui.view.home.scan_qr.ScanQRFragment"
        android:label="fragment_scan_q_r"
        tools:layout="@layout/fragment_scan_q_r" />
    <fragment
        android:id="@+id/restaurantListFragment"
        android:name="com.example.dine.ui.view.home.restaurants.RestaurantListFragment"
        android:label="fragment_restaurant_list"
        tools:layout="@layout/fragment_restaurant_list" >
        <action
            android:id="@+id/action_restaurantListFragment_to_restaruntDetailFragment"
            app:destination="@id/restaruntDetailFragment"
            app:popUpTo="@id/restaurantListFragment" />
    </fragment>
    <fragment
        android:id="@+id/myPlateFragment"
        android:name="com.example.dine.ui.view.home.my_plate.MyPlateFragment"
        android:label="fragment_my_plate"
        tools:layout="@layout/fragment_my_plate" />
    <fragment
        android:id="@+id/accountFragment"
        android:name="com.example.dine.ui.view.home.account.AccountFragment"
        android:label="fragment_account"
        tools:layout="@layout/fragment_account" />
    <fragment
        android:id="@+id/restaruntDetailFragment"
        android:name="com.example.dine.ui.view.restaurant_detail.RestaruntDetailFragment"
        android:label="RestaruntDetailFragment"
        tools:layout="@layout/fragment_restarunt_detail" />
</navigation>
private fun onItemSelected() {
        findNavController().navigate(R.id.action_restaurantListFragment_to_restaruntDetailFragment)
}