List of usage examples for android.view Menu clear
public void clear();
From source file:com.ushahidi.android.presentation.view.ui.activity.PostActivity.java
private void setNavigationViewMenuItems(@NonNull Menu menu) { // Reset menu items to avoid duplicates because we reinitialize them menu.clear(); if (!Utility.isCollectionEmpty(mDeploymentModelList)) { SubMenu subMenu = menu.addSubMenu(Menu.NONE, Menu.FIRST, Menu.NONE, R.string.deployments); subMenu.setGroupCheckable(DEPLOYMENTS_MENU_ITEMS_GROUP_ID, true, true); // Use item position as the menu item's id that way we can retrieve the individual // deployment when user clicks on it to make it the active deployment for (int pos = 0; pos < mDeploymentModelList.size(); pos++) { subMenu.add(DEPLOYMENTS_MENU_ITEMS_GROUP_ID, pos, pos, mDeploymentModelList.get(pos).getTitle()) .setIcon(R.drawable.ic_action_globe); if (mDeploymentModelList.get(pos).getStatus().equals(DeploymentModel.Status.ACTIVATED)) { mNavigationView.getMenu().findItem(pos).setChecked(true); mToolbar.setTitle(mNavigationView.getMenu().findItem(pos).getTitle()); } else { mNavigationView.getMenu().findItem(pos).setChecked(false); }/* w w w. j a v a2 s. c om*/ } } mSubMenuMisc = menu.addSubMenu(Menu.NONE, Menu.FIRST, Menu.NONE, R.string.actions); mSubMenuMisc.add(MISC_MENU_ITEMS, MANAGE_DEPLOYMENT_MENU_ID, 1, R.string.manage_deployments) .setIcon(R.drawable.ic_action_map); mSubMenuMisc.add(MISC_MENU_ITEMS, FEEDBACK_MENU_ID, 2, R.string.send_feedback) .setIcon(R.drawable.ic_action_help); mSubMenuMisc.add(MISC_MENU_ITEMS, ABOUT_MENU_ID, 3, R.string.about).setIcon(R.drawable.ic_action_info); if (mSessionManager.getActiveSession() != null) { mSubMenuMisc.add(MISC_MENU_ITEMS, LOGOUT_MENU_ID, 4, R.string.logout) .setIcon(R.drawable.ic_action_logout); } mSubMenuMisc.setGroupCheckable(MISC_MENU_ITEMS, true, true); }
From source file:org.noorganization.instalist.view.activity.MainShoppingListView.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { boolean drawerOpen = mDrawerLayout.isDrawerOpen(mLeftMenuDrawerRelativeLayout); if (drawerOpen) { menu.clear(); }/*from ww w . j ava 2 s . c om*/ return super.onPrepareOptionsMenu(menu); }
From source file:com.github.jvanhie.discogsscrobbler.NowPlayingFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); //since this fragment will be the only menu producing object in this activity, clear leftovers from strange android screen rotation magic //TODO: move menu items to the activity, would be cleaner I suppose menu.clear(); inflater.inflate(R.menu.now_playing, menu); }
From source file:com.pressurelabs.flowopensource.TheHubActivity.java
@Override public boolean onPrepareOptionsMenu(final Menu menu) { menu.clear(); getMenuInflater().inflate(R.menu.menu_the_hub, menu); MenuItem newF = menu.findItem(R.id.action_new_flow); MenuItem deleteAllF = menu.findItem(R.id.action_delete_flows); if (menuState.equals(AppConstants.MENU_ITEMS_HIDE)) { newF.setVisible(false);// w w w . j ava 2s . c o m deleteAllF.setVisible(false); } return super.onCreateOptionsMenu(menu); }
From source file:me.piebridge.prevent.ui.PreventActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { menu.clear(); if (Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1) { preventMenu = menu.add(Menu.NONE, R.string.prevent, Menu.NONE, R.string.prevent); preventMenu.setIcon(R.drawable.ic_menu_block); preventMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); preventMenu.setVisible(false);//from ww w. ja v a 2s .co m removeMenu = menu.add(Menu.NONE, R.string.remove, Menu.NONE, R.string.remove); removeMenu.setIcon(R.drawable.ic_menu_star); removeMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); removeMenu.setVisible(false); } menu.add(Menu.NONE, R.string.switch_theme, Menu.NONE, R.string.switch_theme); menu.add(Menu.NONE, R.string.system_log, Menu.NONE, R.string.system_log); menu.add(Menu.NONE, R.string.advanced_settings, Menu.NONE, R.string.advanced_settings); menu.add(Menu.NONE, R.string.user_guide, Menu.NONE, R.string.user_guide); return super.onCreateOptionsMenu(menu); }
From source file:com.geecko.QuickLyric.fragment.SettingsFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); MainActivity mainActivity = (MainActivity) this.getActivity(); ActionBar actionBar = (mainActivity).getSupportActionBar(); if (mainActivity.focusOnFragment) // focus is on Fragment {// ww w .j a v a 2s.c om if (actionBar.getTitle() == null || !actionBar.getTitle().equals(this.getString(R.string.settings_title))) actionBar.setTitle(R.string.settings_title); } else menu.clear(); }
From source file:org.spinsuite.view.T_DynamicTab.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); menu.clear(); inflater.inflate(R.menu.dynamic_tab, menu); // Valid is Loaded if (!m_IsLoadOk) return;// ww w .j a v a 2 s.c o m // do it // Get Items mi_Search = menu.getItem(0); mi_Edit = menu.getItem(1); mi_Add = menu.getItem(2); mi_Delete = menu.getItem(3); mi_Cancel = menu.getItem(4); mi_Save = menu.getItem(5); // Lock View changeMenuView(); }
From source file:org.thoughtcrime.securesms.GroupCreateActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { MenuInflater inflater = this.getMenuInflater(); menu.clear(); inflater.inflate(R.menu.group_create, menu); super.onPrepareOptionsMenu(menu); return true;//from w ww . j a v a 2 s .c om }
From source file:org.thoughtcrime.securesms.MediaPreviewActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); menu.clear(); MenuInflater inflater = this.getMenuInflater(); inflater.inflate(R.menu.media_preview, menu); if (!isMediaInDb()) { menu.findItem(R.id.media_preview__overview).setVisible(false); menu.findItem(R.id.delete).setVisible(false); }/*from w ww. j ava2 s . c o m*/ return true; }
From source file:org.chromium.chrome.browser.preferences.website.SingleCategoryPreferences.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { menu.clear(); inflater.inflate(R.menu.website_preferences_menu, menu); MenuItem searchItem = menu.findItem(R.id.search); mSearchView = (SearchView) MenuItemCompat.getActionView(searchItem); mSearchView.setImeOptions(EditorInfo.IME_FLAG_NO_FULLSCREEN); SearchView.OnQueryTextListener queryTextListener = new SearchView.OnQueryTextListener() { @Override/* w ww . j a v a 2s .c o m*/ public boolean onQueryTextSubmit(String query) { return true; } @Override public boolean onQueryTextChange(String query) { if (query.equals(mSearch)) return true; mSearch = query; getInfoForOrigins(); return true; } }; mSearchView.setOnQueryTextListener(queryTextListener); if (mCategory.showProtectedMediaSites()) { // Add a menu item to reset protected media identifier device credentials. MenuItem resetMenu = menu.add(Menu.NONE, Menu.NONE, Menu.NONE, R.string.reset_device_credentials); resetMenu.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { ProtectedContentResetCredentialConfirmDialogFragment.newInstance(SingleCategoryPreferences.this) .show(getFragmentManager(), null); return true; } }); } MenuItem help = menu.add(Menu.NONE, R.id.menu_id_targeted_help, Menu.NONE, R.string.menu_help); help.setIcon(R.drawable.ic_help_and_feedback); }