【发布时间】:2020-07-02 12:00:15
【问题描述】:
所以我创建了默认的导航抽屉活动,并在底部添加了我自己的按钮来手动更改片段。
但是,我不希望这些按钮添加到后退堆栈中,因为我希望导航菜单始终显示汉堡菜单而不是后退按钮。菜单我本质上是想禁用后退按钮和堆栈在我显示时更改导航抽屉上的片段。我将如何实现这一目标?
这是在 onCreate 的导航活动中
setContentView(R.layout.activity_navigation);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
DrawerLayout drawer = findViewById(R.id.drawer_layout);
NavigationView navigationView = findViewById(R.id.nav_view);
// Passing each menu ID as a set of Ids because each
// menu should be considered as top level destinations.
mAppBarConfiguration = new AppBarConfiguration.Builder(
R.id.nav_home, R.id.nav_projects,
R.id.nav_tools, R.id.nav_share, R.id.nav_send)
.setDrawerLayout(drawer)
.build();
this.navController = Navigation.findNavController(this, R.id.nav_host_fragment);
NavigationUI.setupActionBarWithNavController(this, this.navController, mAppBarConfiguration);
NavigationUI.setupWithNavController(navigationView, this.navController);
【问题讨论】:
标签: android android-studio user-interface android-fragments android-activity