【问题标题】:BottonNavigationView Icon not changing on back pressBottomNavigationView 图标在后按时未更改
【发布时间】: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


    【解决方案1】:

    确保在bottomNavView 菜单中具有相同的ID 匹配 bottomNavView 片段的 navGraph 中的相应部分。

    检查this答案

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-01-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-14
      • 2021-04-21
      相关资源
      最近更新 更多