I have a navigationView
with a headerLayout
and also menu
attach to it. I didn't used any library for this one.
I'm trying to achieved the same effect with google navigationView
but the difference is that, not changing account but to view extra's/hidden command (for the admin side if the user is admin).
How do I add/inflate this thing? I have two menu's
. I attempt to do this yet, what I get is, it duplicate itself. Causing the navigationView
to have the same icons and name's. I created two methods, calling them when the image button is clicked.
Here's my code: MainActivity.java
public void changeNavigationDrawer(){
mNavigationView = (NavigationView) findViewById(R.id.navigation_view);
mNavigationView.setItemIconTintList(null);
mNavigationView.getMenu();
mNavigationView.inflateMenu(R.menu.navigation_drawer);
mNavigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(MenuItem menuItem) {
menuItem.setChecked(true);
mDrawerLayout.closeDrawers();
int id = menuItem.getItemId();
switch (id){
//Nav list no 1 is User Profile
//Nav list no 2
case R.id.my_friends:
Intent intent_friends = new Intent(MainActivity.this,CommunityFriendsActivity.class);
startActivity(intent_friends);
finish();
break;
//Nav list no 3
case R.id.my_feeds:
//BY DEFAULT YOU'RE in the FEEDS SECTION
break; }
return true;
}
});
}
The other method in the same file:
public void adminNavigationDrawer(){
mNavigationView = (NavigationView) findViewById(R.id.navigation_view);
mNavigationView.setItemIconTintList(null);
mNavigationView.inflateMenu(R.menu.navigation_drawer_admin);
mNavigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(MenuItem item) {
int id = item.getItemId();
switch (id){
}
return true;
}
});
}