I have to build a menu drawer submenu but I really dont know how to do that, and I haven't found any information about it. The drawer menu has to work this way: when I click on a menu item in the drawer navigation menu, it directs the user to a new drawer menu with new options. the main drawer menu already is built. but I really dont know how to build this sub drawer menu with new options and how to make an action option happen when the user clicks on a submenu item. could you help me with it?
how to direct the user to a new menu(a submenu) when the user clicks on a main menu item?
how to create those submenus?
how to set the action of each sub menu item(how to add the ifs and where to add)?
//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
I don't know exactly what you meant by "direct to a new drawer menu"
If you say a submenu that shows below the menu when clicked, that is a case.
NavigationView has a add submenu() method that can do something if you mean it.
There is a reference that you can look up to.