Hide a Navigation Drawer Menu Item - Android
NavigationView navigationView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
hideItem();
}
private void hideItem()
{
navigationView = (NavigationView) findViewById(R.id.nav_view);
Menu nav_Menu = navigationView.getMenu();
nav_Menu.findItem(R.id.nav_settings).setVisible(false);
}
This will work as setInvisibility(GONE):
Menu nav_Menu = navigationView.getMenu();
nav_Menu.findItem(R.id.nav_profile).setVisible(false);
nav_Menu.findItem(R.id.menu_login).setVisible(true);
nav_Menu.findItem(R.id.menu_logout).setVisible(false);
nav_Menu.findItem(R.id.menu_regsitration).setVisible(true);