List of usage examples for android.view MenuItem setVisible
public MenuItem setVisible(boolean visible);
From source file:nz.ac.auckland.lablet.ExperimentAnalysisFragment.java
protected void setupStandardMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.standard_analysis_actions, menu); final MenuItem doneItem = menu.findItem(R.id.action_done); assert doneItem != null; doneItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override/*ww w . j a v a2 s. c om*/ public boolean onMenuItemClick(MenuItem menuItem) { Activity activity = getActivity(); activity.setResult(Activity.RESULT_OK); activity.finish(); return true; } }); // data menu item ExperimentAnalysisActivity experimentActivity = (ExperimentAnalysisActivity) getActivity(); final ExperimentAnalysis experimentAnalysis = experimentActivity.getExperimentAnalysis(); final MenuItem dataItem = menu.findItem(R.id.action_data); assert dataItem != null; dataItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { showDataMenu(experimentAnalysis); return true; } }); // hide item if there is no more than one data if (experimentAnalysis.getAnalysisRunAt(analysisRef.runId).analysisList.size() == 1) dataItem.setVisible(false); }
From source file:com.pacoapp.paco.ui.FindExperimentsActivity.java
@SuppressLint("NewApi") @Override// w w w .ja v a2s .c o m public boolean onCreateOptionsMenu(Menu menu) { int pos = 1; if (true || !mNavigationDrawerFragment.isDrawerOpen()) { getMenuInflater().inflate(R.menu.main, menu); //restoreActionBar(); // TODO hide find experiments (this is that item) // TODO make refresh be an always action MenuItem findExperiments = menu.getItem(0); findExperiments.setVisible(false); MenuItem refreshExperiments = menu.getItem(1); refreshExperiments.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); return true; } return super.onCreateOptionsMenu(menu); }
From source file:com.android.mail.ui.ActionBarController.java
public boolean onPrepareOptionsMenu(Menu menu) { // We start out with every option enabled. Based on the current view, we disable actions // that are possible. LogUtils.d(LOG_TAG, "ActionBarView.onPrepareOptionsMenu()."); if (mController.shouldHideMenuItems()) { // Shortcut: hide all menu items if the drawer is shown final int size = menu.size(); for (int i = 0; i < size; i++) { final MenuItem item = menu.getItem(i); item.setVisible(false); }/*from w ww . j a va 2s . c om*/ return false; } validateVolatileMenuOptionVisibility(); switch (getMode()) { case ViewMode.CONVERSATION: case ViewMode.SEARCH_RESULTS_CONVERSATION: // We update the ActionBar options when we are entering conversation view because // waiting for the AbstractConversationViewFragment to do it causes duplicate icons // to show up during the time between the conversation is selected and the fragment // is added. setConversationModeOptions(menu); break; case ViewMode.CONVERSATION_LIST: // Show search if the account supports it Utils.setMenuItemVisibility(menu, R.id.search, mAccount.supportsSearch()); break; case ViewMode.SEARCH_RESULTS_LIST: // Hide compose and search Utils.setMenuItemVisibility(menu, R.id.compose, false); Utils.setMenuItemVisibility(menu, R.id.search, false); break; } return false; }
From source file:com.owncloud.android.ui.preview.PreviewImageFragment.java
/** * {@inheritDoc}/*from ww w. j a va2s .c om*/ */ @Override public void onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); if (mContainerActivity.getStorageManager() != null) { // Update the file setFile(mContainerActivity.getStorageManager().getFileById(getFile().getFileId())); FileMenuFilter mf = new FileMenuFilter(getFile(), mContainerActivity.getStorageManager().getAccount(), mContainerActivity, getActivity()); mf.filter(menu); } // additional restriction for this fragment // TODO allow renaming in PreviewImageFragment MenuItem item = menu.findItem(R.id.action_rename_file); if (item != null) { item.setVisible(false); item.setEnabled(false); } // additional restriction for this fragment // TODO allow refresh file in PreviewImageFragment item = menu.findItem(R.id.action_sync_file); if (item != null) { item.setVisible(false); item.setEnabled(false); } // additional restriction for this fragment item = menu.findItem(R.id.action_move); if (item != null) { item.setVisible(false); item.setEnabled(false); } // additional restriction for this fragment item = menu.findItem(R.id.action_copy); if (item != null) { item.setVisible(false); item.setEnabled(false); } }
From source file:com.luorrak.ouroboros.catalog.CatalogFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.menu_catalog, menu); MenuItem replyButton = menu.findItem(R.id.action_reply); MenuItem openExternalButton = menu.findItem(R.id.action_external_browser); MenuItem menuLayout = menu.findItem(R.id.action_menu_layout); MenuItem shareButton = menu.findItem(R.id.menu_item_share); MenuItem sortBy = menu.findItem(R.id.action_sort_by); replyButton.setVisible(true); openExternalButton.setVisible(true); menuLayout.setVisible(true);//from www . j a v a2s . c o m sortBy.setVisible(true); shareButton.setVisible(true); shareActionProvider = MenuItemCompat.getActionProvider(shareButton); MenuItem searchButton = menu.findItem(R.id.action_search); searchButton.setVisible(true); SearchView searchView = (SearchView) searchButton.getActionView(); searchView.setIconifiedByDefault(false); searchView.setSubmitButtonEnabled(false); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { return false; } @Override public boolean onQueryTextChange(String newText) { Log.d(LOG_TAG, "query=" + newText); catalogAdapter.setFilterQueryProvider(new FilterQueryProvider() { @Override public Cursor runQuery(CharSequence constraint) { return infiniteDbHelper.searchCatalogForThread(constraint.toString(), SettingsHelper.getSortByMethod(getContext())); } }); catalogAdapter.getFilter().filter(newText); return true; } }); }
From source file:de.vanita5.twittnuker.fragment.support.DirectMessagesConversationFragment.java
private void showMenu(final View view, final ParcelableDirectMessage dm) { if (mPopupMenu != null && mPopupMenu.isShowing()) { mPopupMenu.dismiss();// w ww .j a va 2 s. c om } final Context context = ThemeUtils.getThemedContextForActionIcons(getActivity()); mPopupMenu = PopupMenu.getInstance(context, view); mPopupMenu.inflate(R.menu.action_direct_message); final Menu menu = mPopupMenu.getMenu(); final MenuItem view_profile_item = menu.findItem(MENU_VIEW_PROFILE); if (view_profile_item != null && dm != null) { view_profile_item.setVisible(dm.account_id != dm.sender_id); } mPopupMenu.setOnMenuItemClickListener(this); mPopupMenu.show(); }
From source file:com.afollestad.polar.ui.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.main, menu); if (!Config.get().changelogEnabled()) menu.findItem(R.id.changelog).setVisible(false); MenuItem darkTheme = menu.findItem(R.id.darkTheme); if (!Config.get().allowThemeSwitching()) darkTheme.setVisible(false); else//from w w w. ja v a 2 s.c o m darkTheme.setChecked(darkTheme()); MenuItem navDrawerMode = menu.findItem(R.id.navDrawerMode); if (Config.get().navDrawerModeAllowSwitch()) { navDrawerMode.setVisible(true); navDrawerMode.setChecked(Config.get().navDrawerModeEnabled()); } return super.onCreateOptionsMenu(menu); }
From source file:com.pemikir.youtubeplus.ActionBarHandler.java
public boolean setupMenu(Menu menu, MenuInflater inflater, Context context) { this.context = context; // CAUTION set item properties programmatically otherwise it would not be accepted by // appcompat itemsinflater.inflate(R.menu.videoitem_detail, menu); defaultPreferences = PreferenceManager.getDefaultSharedPreferences(context); inflater.inflate(R.menu.videoitem_detail, menu); MenuItem playItem = menu.findItem(R.id.menu_item_play); MenuItem shareItem = menu.findItem(R.id.menu_item_share); MenuItem castItem = menu.findItem(R.id.action_play_with_kodi); MenuItemCompat.setShowAsAction(playItem, MenuItemCompat.SHOW_AS_ACTION_ALWAYS | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT); MenuItemCompat.setShowAsAction(shareItem, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT); castItem.setVisible( defaultPreferences.getBoolean(context.getString(R.string.showPlayWidthKodiPreference), false)); return true;//from w w w . j ava 2 s . c om }
From source file:de.jerleo.samsung.knox.firewall.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu, menu); boolean allowed = (mViewPager.getCurrentItem() == 0); boolean hasAdmin = hasActiveAdministrator(); boolean hasLicense = hasActiveLicense(); MenuItem itemAdmin = menu.findItem(R.id.action_admin); MenuItem itemLicense = menu.findItem(R.id.action_license); MenuItem itemAllow = menu.findItem(R.id.action_allow_selected); MenuItem itemDeny = menu.findItem(R.id.action_deny_selected); MenuItem itemApply = menu.findItem(R.id.action_apply_rules); // Set visibility of options menu items itemAdmin.setEnabled(!hasAdmin);/*w w w . j a v a 2 s. co m*/ itemLicense.setEnabled(hasAdmin && !hasLicense); itemAllow.setEnabled(hasAdmin && hasLicense); itemAllow.setVisible(!allowed); itemDeny.setEnabled(hasAdmin && hasLicense); itemDeny.setVisible(allowed); itemApply.setEnabled(hasAdmin && hasLicense); invalidateOptionsMenu(); return true; }
From source file:com.esri.android.mapsapp.tools.MeasuringTool.java
@Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { mMode = mode;/* w ww.j a v a2 s . c om*/ init(); MenuItem item; item = menu.add(Menu.NONE, MENU_UNDO, 1, "undo"); item.setIcon(android.R.drawable.ic_menu_revert); item.setVisible(false); item = menu.add(Menu.NONE, MENU_DELETE, 2, "clear"); item.setIcon(android.R.drawable.ic_menu_delete); item.setVisible(false); item = menu.add(Menu.NONE, MENU_PREF, 3, "preferences"); item.setIcon(android.R.drawable.ic_menu_manage); item.setActionProvider(new Preferences(mContext)); return true; }