【发布时间】:2022-10-14 22:13:32
【问题描述】:
我正在使用导航组件作为底部导航组件。
bottomNavbar.setupWithNavController(navController)
现在这工作正常但是当我点击后退按钮时,它正在返回主页但图标没有改变,它卡在上一个选定的片段中。我有三个片段,我在所有这些片段中分别实现了导航栏,这是这三个片段的代码。
设置片段
val bottomNavbar = view.findViewById<BottomNavigationView>(R.id.bottomNavbar)
bottomNavbar.setupWithNavController(navController)
搜索片段
val bottomNavbar = view.findViewById<BottomNavigationView>(R.id.bottomNavbarSearch)
bottomNavbar.setupWithNavController(navController)
聊天片段
val bottomNavbar = view.findViewById<BottomNavigationView>(R.id.bottomNavbar)
bottomNavbar.setupWithNavController(navController)
这里的搜索片段是我的家庭片段。
我的实现是否有错误,或者我应该切换到实现底部导航视图的旧方式。
任何帮助表示赞赏。谢谢
【问题讨论】:
标签: android android-studio android-fragments bottomnavigationview android-navigation