硬件后退按钮不会更新工具栏标题和导航按钮

时间:2019-09-04 18:23:23

标签: android navigation material-design android-toolbar

我有导航抽屉,工具栏作为顶部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);

0 个答案:

没有答案