当我点击菜单项时,如何更改 android studio 应用程序抽屉菜单中显示的内容?
How to change the content shown in the drawer menu in android studio application when I click on a menu item?
我必须建立一个菜单抽屉子菜单,但我真的不知道该怎么做,而且我还没有找到任何相关信息。抽屉菜单必须以这种方式工作:当我单击抽屉导航菜单中的菜单项时,它会将用户定向到一个带有新选项的新抽屉菜单。主抽屉菜单已经建成。但我真的不知道如何使用新选项构建此子抽屉菜单,以及如何在用户单击子菜单项时使操作选项发生。你能帮我吗?
如何在用户单击主菜单项时将用户定向到新菜单(子菜单)?
如何创建这些子菜单?
如何设置每个子菜单项的动作(如何添加ifs以及在何处添加)?
//here's the main menu onNavigationItemSelected
public boolean onNavigationItemSelected(MenuItem item) {
// Handle navigation view item clicks here.
int id = item.getItemId();
if (id == R.id.nav_home) {
//here I have to open a new menu drawer
} else if (id == R.id.nav_grade1) {
//here I have to open another new menu drawer
} else if (id == R.id.nav_grade2){
//open another submenu
}
else if (id == R.id.nav_grade3){
//open another submenu
} else if (id == R.id.nav_shapes){
//open another submenu
}
}
enter code here
我不明白你的意思 "direct to a new drawer menu"
如果你说的是点击时显示在菜单下方的子菜单,就是这种情况。
NavigationView 有一个 add submenu() 方法,如果您愿意,它可以做一些事情。
有一个参考,您可以查阅。
我必须建立一个菜单抽屉子菜单,但我真的不知道该怎么做,而且我还没有找到任何相关信息。抽屉菜单必须以这种方式工作:当我单击抽屉导航菜单中的菜单项时,它会将用户定向到一个带有新选项的新抽屉菜单。主抽屉菜单已经建成。但我真的不知道如何使用新选项构建此子抽屉菜单,以及如何在用户单击子菜单项时使操作选项发生。你能帮我吗?
如何在用户单击主菜单项时将用户定向到新菜单(子菜单)?
如何创建这些子菜单?
如何设置每个子菜单项的动作(如何添加ifs以及在何处添加)?
//here's the main menu onNavigationItemSelected
public boolean onNavigationItemSelected(MenuItem item) {
// Handle navigation view item clicks here.
int id = item.getItemId();
if (id == R.id.nav_home) {
//here I have to open a new menu drawer
} else if (id == R.id.nav_grade1) {
//here I have to open another new menu drawer
} else if (id == R.id.nav_grade2){
//open another submenu
}
else if (id == R.id.nav_grade3){
//open another submenu
} else if (id == R.id.nav_shapes){
//open another submenu
}
}
enter code here
我不明白你的意思 "direct to a new drawer menu"
如果你说的是点击时显示在菜单下方的子菜单,就是这种情况。
NavigationView 有一个 add submenu() 方法,如果您愿意,它可以做一些事情。
有一个参考,您可以查阅。