just use below way
nav_draw = (NavigationView) findViewById(R.id.nav_draw);
nav_draw.getMenu().findItem(R.id.navigation_item_1).setVisible(false);
You can get the item by
navigationView.Menu.GetItem(menu_index)
View navHeader=navigationView.getHeaderView(0);[![enter image description here][1]][1]
navMenu=navigationView.getMenu();
List item
//work for login and logout menu
if (MyPreferences.getBoolean(BaseActivity.this,ConstantValues.KEY_IS_LOGIN)){
navMenu.getItem(0).setVisible(false);
navMenu.getItem(9).setVisible(true);
}else {
navMenu.getItem(0).setVisible(true);
navMenu.getItem(9).setVisible(false);
}
You can get that by method of NavigationView.getMenu()
Menu menuNav = mNavigationView.getMenu();
Then you can find specific item by
MenuItem logoutItem = menuNav.findItem(R.id.menu_logout);
I think you should first get the menu like this:
navigationView.getMenu().findItem(R.id.login).setVisible(false);
The main aspect of this code is calling navigationView.getMenu() to get the menu from this you will have a reference of current inflated menu and call findViewById() and after that you can whatever you what.
For Group of item ex:-
<group
android:id="@+id/group_1"
android:checkableBehavior="single"
android:visible="false">
...
and then you can control this using :-
navigationView.getMenu().setGroupVisible(R.id.group_1, true)