How to have two navigation drawer and show them according to some parameter


Hi, I am doing a project in android studio and I have two navigation drawer, what I want to do is that when I start as a client I show the first navigation and if I start session as an employee that shows me the other navigation. I have investigated and the only thing I could do is to show one on the left and the other on the right. I do not know how to make it show only one depending on whether you are a client or if you are an employee.


asked by Jean Pierre Acosta Tomaylla 26.10.2018 в 02:52

1 answer


That is done with a if/else .

First in your xml just leave a widget.NavigationView with id / nav_view and from there delete app: menu ...

In java you will select the drawer menu:

 String vista="";             // obtienes el string para cliente/empleado
 navigationView = (NavigationView) findViewById(;   // la vista del menu drawer
   //navigationView.getMenu().clear();      //elimina anterior menu drawer
   navigationView.inflateMenu(; //carga el menu drawer
 }else                                  // en caso de "empleado"

You declare the navigation view and the String view at the beginning of the class, before onCreate:

 NavigationView navigationView;
 String vista="";
answered by 27.10.2018 / 02:05