如何解决导航片段显示了导航体系结构组件jetpack中先前片段的后面
<?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)
}
我在某个动作上调用了 onItemSelected()方法,任何帮助都将非常有用。谢谢
从餐厅列表导航到RestaurantDetail片段时,就像这样。很久以来我一直在遭受这个问题的困扰
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。