How to hide menus on Android

0

As shown in the image I need to hide certain menus depending on the type of account.

I'm using the Navigation Drawer Activity, I've seen that in the onCreateOptionsMenu I can do it but I do not really know how to do that, someone to help me.

    
asked by DoubleM 29.01.2017 в 06:22
source

2 answers

2

You can hide the items once you have the NavigationView reference. For example.

navigationView.getMenu().findItem(R.id.action_registrar_corte).setVisible(false);
navigationView.getMenu().findItem(R.id.action_mostrar_corte).setVisible(true);

Greetings.

    
answered by 29.01.2017 / 06:27
source
0

In this menu you can choose not to show a group instead of all the elements of the group by:

navigationView.getMenu().setGroupVisible(R.id.grupo1, false);

Or an element of the group:

navigationView.getMenu().findItem(R.id.elemento1).setVisible(false);
    
answered by 29.01.2017 в 09:00