For now I'm setting the menu through xml, this way:
<android.support.design.widget.NavigationView
android:id="@+id/navView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@color/colorBackgroud"
app:headerLayout="@layout/nav_header"
app:itemIconTint="@color/textColorPrimary"
app:itemTextColor="@color/textColorPrimary"
app:menu="@menu/menu_nav">
But before I set the menu to do a check with if, for this I would need to set it by code, for example ... if (if) user was equal to "administrator" open a menu other than "users" ".
Follow my code for now:
NavigationView navigationView = (NavigationView) findViewById(R.id.navView);
navigationView.setNavigationItemSelectedListener(this);
How do I set the navigationview menu by code?