Java Code Examples for android.support.design.widget.NavigationView#inflateMenu()
The following examples show how to use
android.support.design.widget.NavigationView#inflateMenu() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseDrawerActivity.java From OpenHub with GNU General Public License v3.0 | 5 votes |
private void updateDrawerContent(NavigationView navView, int menuId) { if (drawerLayout != null && navView != null) { navView.getMenu().clear(); navView.inflateMenu(menuId); if (drawerLayout.indexOfChild(navView) == -1) drawerLayout.addView(navView); } }
Example 2
Source File: MenuActivity.java From dhis2-android-datacapture with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_menu); drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); navigationView = (NavigationView) findViewById(R.id.navigation_view); if (navigationView != null) { navigationView.inflateMenu(R.menu.menu_drawer); navigationView.setNavigationItemSelectedListener(this); } toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); if (toolbar != null) { toolbar.setNavigationIcon(R.drawable.ic_menu); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { toggleNavigationDrawer(); } }); } if (savedInstanceState == null) { onNavigationItemSelected(navigationView.getMenu() .findItem(R.id.drawer_item_aggregate_report)); } else if (savedInstanceState.containsKey(STATE_TOOLBAR_TITLE) && toolbar != null) { setTitle(savedInstanceState.getString(STATE_TOOLBAR_TITLE)); } if(ViewUtils.fragmentSelected != null) { attachFragment(ViewUtils.fragmentSelected); setTitle(ViewUtils.title); } }