List of usage examples for android.view MenuItem setEnabled
public MenuItem setEnabled(boolean enabled);
From source file:com.battlelancer.seriesguide.ui.MovieDetailsFragment.java
@Override public void onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); if (mMovieDetails != null) { boolean isEnableShare = mMovieDetails.tmdbMovie() != null && !TextUtils.isEmpty(mMovieDetails.tmdbMovie().title); MenuItem shareItem = menu.findItem(R.id.menu_movie_share); shareItem.setEnabled(isEnableShare); shareItem.setVisible(isEnableShare); if (!Utils.isAmazonVersion()) { MenuItem playStoreItem = menu.findItem(R.id.menu_open_google_play); playStoreItem.setEnabled(isEnableShare); playStoreItem.setVisible(isEnableShare); }/*from ww w. j a va 2 s .c o m*/ boolean isEnableImdb = mMovieDetails.traktMovie() != null && !TextUtils.isEmpty(mMovieDetails.traktMovie().imdb_id); MenuItem imdbItem = menu.findItem(R.id.menu_open_imdb); imdbItem.setEnabled(isEnableImdb); imdbItem.setVisible(isEnableImdb); boolean isEnableYoutube = mTrailers != null && mTrailers.youtube.size() > 0; MenuItem youtubeItem = menu.findItem(R.id.menu_open_youtube); youtubeItem.setEnabled(isEnableYoutube); youtubeItem.setVisible(isEnableYoutube); } }
From source file:org.apache.cordova.plugins.Actionable.java
public void buildMenu() { for (Actionable act : mMenuItems.values()) { MenuItem mi = mMenu.add(Menu.NONE, Menu.NONE, act.getOrder(), act.getTitle()); mi.setTitleCondensed(act.getTitle()); mi.setShowAsAction(act.getFlags()); if (act.isDisabled()) { mi.setEnabled(false); }/*from w ww. j av a 2 s . com*/ if (act.getIcon() != null) { mi.setIcon(act.getIcon()); } } }
From source file:it.gulch.linuxday.android.activities.MainActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { // Hide & disable primary (contextual) action items when the main menu is opened if (drawerLayout.isDrawerOpen(mainMenu)) { final int size = menu.size(); for (int i = 0; i < size; ++i) { MenuItem item = menu.getItem(i); if ((item.getOrder() & 0xFFFF0000) == 0) { item.setVisible(false).setEnabled(false); }/*from ww w . j ava2 s . c o m*/ } } MenuItem refreshMenuItem = menu.findItem(R.id.refresh); boolean isRefreshing = refreshItem != null; Log.d(TAG, "isRefreshing: " + Boolean.toString(isRefreshing)); refreshMenuItem.setEnabled(!isRefreshing); return super.onPrepareOptionsMenu(menu); }
From source file:com.cerema.cloud2.ui.preview.PreviewImageFragment.java
/** * {@inheritDoc}/* w w w . ja v a2 s .c o m*/ */ @Override public void onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); if (mContainerActivity.getStorageManager() != null && getFile() != 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:fr.outadev.skinswitch.DetailActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.skin_details, menu); MenuItem shareItem = menu.findItem(R.id.action_share); if (skin instanceof CustomUriSkin) { ShareActionProvider shareActionProvider = (ShareActionProvider) MenuItemCompat .getActionProvider(shareItem); shareActionProvider.setShareIntent(getDefaultIntent()); shareItem.setEnabled(true); } else {/*from w w w. j a v a 2 s . c o m*/ shareItem.setEnabled(false); } return true; }
From source file:com.esri.android.rt.map.PopupFragment.java
@Override public void onPrepareOptionsMenu(Menu menu) { // Turn on/off menu items based on popup's edit capabilities for (int i = 0; i < menu.size(); i++) { MenuItem item = menu.getItem(i); if (mPopupContainer != null) { Popup popup = mPopupContainer.getCurrentPopup(); if (popup != null) { if (popup.isEditMode()) { if (item.getItemId() == R.id.menu_save || item.getItemId() == R.id.menu_camera) { item.setVisible(true); item.setEnabled(true); } else { item.setVisible(false); item.setEnabled(false); }//from w w w.ja v a 2 s . c om } else { if (((item.getItemId() == R.id.menu_edit) && (popup.isEditable())) || ((item.getItemId() == R.id.menu_delete) && (popup.isDeletable()))) { item.setVisible(true); item.setEnabled(true); } else { item.setVisible(false); item.setEnabled(false); } } } else { item.setVisible(false); item.setEnabled(false); } } else { item.setVisible(false); item.setEnabled(false); } } }
From source file:com.owncloud.android.ui.preview.PreviewImageFragment.java
/** * {@inheritDoc}/*w ww . ja v a2s . co m*/ */ @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.gh4a.fragment.PullRequestFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.pullrequest_menu, menu); Gh4Application app = Gh4Application.get(); boolean authorized = app.isAuthorized(); boolean isCreator = ApiHelpers.loginEquals(mPullRequest.getUser(), app.getAuthLogin()); boolean canOpenOrClose = authorized && (isCreator || mIsCollaborator); boolean canMerge = authorized && mIsCollaborator; if (!canOpenOrClose) { menu.removeItem(R.id.pull_close); menu.removeItem(R.id.pull_reopen); } else if (Constants.Issue.STATE_CLOSED.equals(mPullRequest.getState())) { menu.removeItem(R.id.pull_close); if (mPullRequest.isMerged()) { menu.findItem(R.id.pull_reopen).setEnabled(false); }// w w w . j a va 2 s .c om } else { menu.removeItem(R.id.pull_reopen); } if (!canMerge) { menu.removeItem(R.id.pull_merge); } else if (mPullRequest.isMerged() || !mPullRequest.isMergeable()) { MenuItem mergeItem = menu.findItem(R.id.pull_merge); mergeItem.setEnabled(false); } super.onCreateOptionsMenu(menu, inflater); }
From source file:com.hyperaware.conference.android.activity.MainActivity.java
@Override public boolean onCreateOptionsMenu(final Menu menu) { getMenuInflater().inflate(R.menu.main, menu); final MenuItem item = menu.findItem(R.id.mi_fake_date_time); if (item != null) { item.setEnabled(BuildConfig.ALLOW_FAKE_TIME); item.setVisible(BuildConfig.ALLOW_FAKE_TIME); }/* w w w.j a va 2 s .co m*/ super.onCreateOptionsMenu(menu); return true; }
From source file:org.xbmc.kore.ui.AbstractListFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.abstractlistfragment, menu); if (gridViewUsesMultipleColumns) { if (PreferenceManager.getDefaultSharedPreferences(getActivity()) .getBoolean(Settings.KEY_PREF_SINGLE_COLUMN, Settings.DEFAULT_PREF_SINGLE_COLUMN)) { gridView.setNumColumns(1);//from ww w .j a v a 2 s . co m adapter.notifyDataSetChanged(); MenuItem item = menu.findItem(R.id.action_multi_single_columns); item.setTitle(R.string.multi_column); } } else { //Default number of columns for GridView is set to AUTO_FIT. //When this leads to a single column it is not possible //to switch to multiple columns. We therefore disable //the menu item. MenuItem item = menu.findItem(R.id.action_multi_single_columns); item.setTitle(R.string.multi_column); item.setEnabled(false); } super.onCreateOptionsMenu(menu, inflater); }