我有导航抽屉,工具栏作为顶部AppBar,并具有图形,NavController和片段导航。一切正常。除了硬件后退按钮。在这种情况下,目标位置已更改,但工具栏未更新。
初始化:
setContentView(R.layout.activity_main);
navController = Navigation.findNavController(this, R.id.nav_host_fragment);
drawerLayout = findViewById(R.id.drawer_layout);
toolbar = findViewById(R.id.main_toolbar);
AppBarConfiguration appBarConfiguration =
new AppBarConfiguration.Builder(R.id.mainMenu, R.id.scheduleFragment, R.id.statFragment)
.setDrawerLayout(drawerLayout)
.build();
NavigationUI.setupWithNavController(toolbar, navController, appBarConfiguration);
NavigationView navigationView = findViewById(R.id.main_navigation_view);
NavigationUI.setupWithNavController(navigationView, navController);