List of usage examples for android.view MenuItem setEnabled
public MenuItem setEnabled(boolean enabled);
From source file:com.github.pockethub.ui.gist.GistFragment.java
@Override public void onPrepareOptionsMenu(Menu menu) { boolean owner = isOwner(); if (!owner) { menu.removeItem(R.id.m_delete);//from w w w . j a v a2 s .c o m MenuItem starItem = menu.findItem(R.id.m_star); starItem.setEnabled(loadFinished && !owner); if (starred) starItem.setTitle(R.string.unstar); else starItem.setTitle(R.string.star); } else menu.removeItem(R.id.m_star); }
From source file:com.duy.pascal.ui.file.FileExplorerAction.java
@Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { menu.add(0, R.id.select_all, 0, R.string.select_all).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); menu.add(0, R.id.cut, 0, R.string.cut).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); menu.add(0, R.id.copy, 0, R.string.copy).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); MenuItem pasteMenu = menu.add(0, R.id.paste, 0, R.string.paste); pasteMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); pasteMenu.setEnabled(mFileClipboard.canPaste()); mRenameMenu = menu.add(0, R.id.rename, 0, R.string.rename); mRenameMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); mShareMenu = menu.add(0, R.id.share, 0, R.string.share); mShareMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); mShareActionProvider = new ShareActionProvider(mContext); mShareActionProvider.setOnShareTargetSelectedListener(this); MenuItemCompat.setActionProvider(mShareMenu, mShareActionProvider); menu.add(0, R.id.delete, 0, R.string.delete).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); return true;/*w ww .j a v a 2 s . c o m*/ }
From source file:com.vuze.android.remote.activity.RcmActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { if (AndroidUtils.DEBUG_MENU) { Log.d(TAG, "onPrepareOptionsMenu"); }// w w w. j av a 2 s .c o m if (!onPrepareOptionsMenu_drawer(menu)) { return true; } MenuItem menuDownload = menu.findItem(R.id.action_download); if (menuDownload != null) { menuDownload.setEnabled(adapter != null && adapter.getCheckedItemCount() > 0); } AndroidUtils.fixupMenuAlpha(menu); return super.onPrepareOptionsMenu(menu); }
From source file:com.synox.android.ui.preview.PreviewImageFragment.java
/** * {@inheritDoc}/*from w ww. java 2 s.com*/ */ @Override public void onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); if (mContainerActivity != null && 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) { if (getFile().isDown()) { item.setVisible(false); item.setEnabled(false); } else { item.setVisible(true); item.setEnabled(true); } } // additional restriction for this fragment // TODO allow refresh file in PreviewImageFragment item = menu.findItem(R.id.action_download_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_send_file); if (item != null && !getFile().isDown()) { 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:net.sf.golly.HelpActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { // add main.xml items to the action bar getMenuInflater().inflate(R.menu.main, menu); // disable the item for this activity MenuItem item = menu.findItem(R.id.help); item.setEnabled(false); return true;//ww w. jav a 2s . co m }
From source file:com.jefftharris.passwdsafe.FileListFragment.java
@Override public void onPrepareOptionsMenu(Menu menu) { MenuItem item = menu.findItem(R.id.menu_file_new); item.setEnabled(itsListener.appHasFilePermission()); super.onPrepareOptionsMenu(menu); }
From source file:prince.app.sphotos.Activity_Photos.java
@Override protected void hideShowMenu(Menu menu) { // show details MenuItem item = menu.findItem(R.id.action_details); item.setEnabled(true); if (FBINIT.isAlbumEmpty()) { item.setVisible(false);/*from www. j a v a 2 s . com*/ } else { item.setVisible(true); } }
From source file:com.owncloud.android.files.FileMenuFilter.java
/** * Filters out the file actions available in the passed {@link Menu} taken into account * the state of the {@link OCFile} held by the filter. * * @param menu Options or context menu to filter. *///from w ww.ja v a 2 s . c o m public void filter(Menu menu, boolean displaySelectAll, boolean displaySelectInverse) { if (mFiles == null || mFiles.size() <= 0) { hideAll(menu); } else { List<Integer> toShow = new ArrayList<>(); List<Integer> toHide = new ArrayList<>(); filter(toShow, toHide, displaySelectAll, displaySelectInverse); MenuItem item; for (int i : toShow) { item = menu.findItem(i); if (item != null) { item.setVisible(true); item.setEnabled(true); } } for (int i : toHide) { item = menu.findItem(i); if (item != null) { item.setVisible(false); item.setEnabled(false); } } } }
From source file:org.sufficientlysecure.keychain.ui.CreateKeyFinalFragment.java
@Override public void onPrepareOptionsMenu(Menu menu) { CreateKeyActivity createKeyActivity = (CreateKeyActivity) getActivity(); MenuItem editItem = menu.findItem(R.id.menu_create_key_edit); editItem.setEnabled(!createKeyActivity.mCreateSecurityToken); super.onPrepareOptionsMenu(menu); }
From source file:com.uwetrottmann.wpdisplay.ui.DisplayFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.menu_display, menu); boolean paused = ConnectionTools.get().isPaused(); MenuItem item = menu.findItem(R.id.menu_action_display_pause); item.setIcon(paused ? R.drawable.ic_play_arrow_white_24dp : R.drawable.ic_pause_white_24dp); item.setTitle(paused ? R.string.action_resume : R.string.action_pause); item.setEnabled(isConnected); item.setVisible(isConnected);// w w w . java2 s . c o m }