List of usage examples for android.view Menu findItem
public MenuItem findItem(int id);
From source file:com.amagi82.kerbalspaceapp.CelestialBodyActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.celestial_body, menu); if (mCurrentPage >= 4 && mCurrentPage <= 6) { menu.findItem(R.id.action_biomes).setVisible(true); mBiomesPage = mCurrentPage - 4;//from w ww .j a va2s .c om } else { menu.findItem(R.id.action_biomes).setVisible(false); } if (mCurrentPage == 0 || mCurrentPage == 10) { menu.findItem(R.id.action_topography).setVisible(false); } else { menu.findItem(R.id.action_topography).setVisible(true); mTopographyPage = mCurrentPage + 2; } if (mCurrentPage == 2 || mCurrentPage == 7) { menu.findItem(R.id.action_atmosphere).setVisible(true); mAtmospherePage = mCurrentPage + 17; } else { menu.findItem(R.id.action_atmosphere).setVisible(false); } return true; }
From source file:cn.edu.wyu.documentviewer.DocumentsActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); final FragmentManager fm = getFragmentManager(); final RootInfo root = getCurrentRoot(); final DocumentInfo cwd = getCurrentDirectory(); final MenuItem createDir = menu.findItem(R.id.menu_create_dir); final MenuItem search = menu.findItem(R.id.menu_search); final MenuItem sort = menu.findItem(R.id.menu_sort); final MenuItem sortSize = menu.findItem(R.id.menu_sort_size); final MenuItem grid = menu.findItem(R.id.menu_grid); final MenuItem list = menu.findItem(R.id.menu_list); final MenuItem settings = menu.findItem(R.id.menu_settings); // Open drawer means we hide most actions if (isRootsDrawerOpen()) { createDir.setVisible(false);// w w w.j av a 2s . c o m search.setVisible(false); sort.setVisible(false); grid.setVisible(false); list.setVisible(false); mIgnoreNextCollapse = true; search.collapseActionView(); return true; } sort.setVisible(cwd != null); grid.setVisible(mState.derivedMode != MODE_GRID); list.setVisible(mState.derivedMode != MODE_LIST); if (mState.currentSearch != null) { // Search uses backend ranking; no sorting sort.setVisible(false); search.expandActionView(); mSearchView.setIconified(false); mSearchView.clearFocus(); mSearchView.setQuery(mState.currentSearch, false); } else { mIgnoreNextClose = true; mSearchView.setIconified(true); mSearchView.clearFocus(); mIgnoreNextCollapse = true; search.collapseActionView(); } // Only sort by size when visible sortSize.setVisible(mState.showSize); final boolean searchVisible; if (mState.action == ACTION_CREATE) { createDir.setVisible(cwd != null && cwd.isCreateSupported()); searchVisible = false; // No display options in recent directories if (cwd == null) { grid.setVisible(false); list.setVisible(false); } SaveFragment.get(fm).setSaveEnabled(cwd != null && cwd.isCreateSupported()); } else { createDir.setVisible(false); searchVisible = root != null && ((root.flags & Root.FLAG_SUPPORTS_SEARCH) != 0); } // TODO: close any search in-progress when hiding search.setVisible(searchVisible); settings.setVisible(mState.action != ACTION_MANAGE); return true; }
From source file:com.krayzk9s.imgurholo.ui.SingleImageFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { ImgurHoloActivity activity = (ImgurHoloActivity) getActivity(); if (activity.getApiCall().settings.getString("theme", MainActivity.HOLO_LIGHT) .equals(MainActivity.HOLO_LIGHT)) inflater.inflate(R.menu.main, menu); else/*from w w w . ja v a2 s. c o m*/ inflater.inflate(R.menu.main_dark, menu); if (imageData.getJSONObject().has("deletehash")) { menu.findItem(R.id.action_delete).setVisible(true); menu.findItem(R.id.action_edit).setVisible(true); menu.findItem(R.id.action_submit).setVisible(true); } menu.findItem(R.id.action_share).setVisible(true); menu.findItem(R.id.action_download).setVisible(true); menu.findItem(R.id.action_copy).setVisible(true); menu.findItem(R.id.action_refresh).setVisible(true); menu.findItem(R.id.action_upload).setVisible(false); menu.findItem(R.id.action_sort).setVisible(true); menu.findItem(R.id.action_sort).getSubMenu().findItem(R.id.menuSortNewest).setVisible(true); menu.findItem(R.id.action_sort).getSubMenu().findItem(R.id.menuSortBest).setVisible(true); menu.findItem(R.id.action_sort).getSubMenu().findItem(R.id.menuSortPopularity).setVisible(false); }
From source file:au.com.wallaceit.reddinator.SubredditSelectActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.subreddit_select_menu, menu); // set options menu view int iconColor = Color.parseColor("#DBDBDB"); (menu.findItem(R.id.menu_submit)) .setIcon(new IconDrawable(this, Iconify.IconValue.fa_pencil).color(iconColor).actionBarSize()); (menu.findItem(R.id.menu_feedprefs)) .setIcon(new IconDrawable(this, Iconify.IconValue.fa_list_alt).color(iconColor).actionBarSize()); if (mAppWidgetId == 0) { (menu.findItem(R.id.menu_widgettheme)).setEnabled(false); }/*from ww w .ja va2 s. co m*/ (menu.findItem(R.id.menu_widgettheme)) .setIcon(new IconDrawable(this, Iconify.IconValue.fa_paint_brush).color(iconColor).actionBarSize()); (menu.findItem(R.id.menu_thememanager)) .setIcon(new IconDrawable(this, Iconify.IconValue.fa_cogs).color(iconColor).actionBarSize()); (menu.findItem(R.id.menu_account)).setIcon( new IconDrawable(this, Iconify.IconValue.fa_reddit_square).color(iconColor).actionBarSize()); (menu.findItem(R.id.menu_prefs)) .setIcon(new IconDrawable(this, Iconify.IconValue.fa_wrench).color(iconColor).actionBarSize()); (menu.findItem(R.id.menu_about)) .setIcon(new IconDrawable(this, Iconify.IconValue.fa_info_circle).color(iconColor).actionBarSize()); return super.onCreateOptionsMenu(menu); }
From source file:org.planetmono.dcuploader.ActivityUploader.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater mi = getMenuInflater(); mi.inflate(R.menu.uploader, menu);// w w w . j a v a2s . c o m Application app = (Application) getApplication(); if (!app.isSignedOn()) menu.findItem(R.id.menu_uploader_sign_off).setEnabled(false); return true; }
From source file:com.android.app.MediaPlaybackActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { if (mService == null) return false; MenuItem item = menu.findItem(PARTY_SHUFFLE); if (item != null) { int shuffle = MusicUtils.getCurrentShuffleMode(); if (shuffle == MediaPlaybackService.SHUFFLE_AUTO) { item.setIcon(R.drawable.ic_menu_party_shuffle); item.setTitle(R.string.party_shuffle_off); } else {// ww w . java 2 s . c o m item.setIcon(R.drawable.ic_menu_party_shuffle); item.setTitle(R.string.party_shuffle); } } item = menu.findItem(ADD_TO_PLAYLIST); if (item != null) { SubMenu sub = item.getSubMenu(); MusicUtils.makePlaylistMenu(this, sub); } KeyguardManager km = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE); menu.setGroupVisible(1, !km.inKeyguardRestrictedInputMode()); return true; }
From source file:com.github.chenxiaolong.dualbootpatcher.patcher.PatchFileFragment.java
/** * {@inheritDoc}/*from w w w .j a v a2 s . c o m*/ */ @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.actionbar_check_cancel, menu); // NOTE: May crash on some versions of Android due to a bug where getActivity() returns null // after onAttach() has been called, but before onDetach() has been called. It's similar to // this bug report, except it happens with android.app.Fragment: // https://code.google.com/p/android/issues/detail?id=67519 int primary = ContextCompat.getColor(getActivity(), R.color.text_color_primary); MenuUtils.tintAllMenuIcons(menu, primary); mCheckItem = menu.findItem(R.id.check_item); mCancelItem = menu.findItem(R.id.cancel_item); updateToolbarIcons(); super.onCreateOptionsMenu(menu, inflater); }
From source file:cn.edu.wyu.documentviewer.DocumentsActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); getMenuInflater().inflate(R.menu.activity, menu); // Actions are always visible when showing as dialog if (mShowAsDialog) { for (int i = 0; i < menu.size(); i++) { menu.getItem(i).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); }/*from w ww . ja v a2 s .c om*/ } final MenuItem searchMenu = menu.findItem(R.id.menu_search); mSearchView = (SearchView) searchMenu.getActionView(); mSearchView.setOnQueryTextListener(new OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { mState.currentSearch = query; mSearchView.clearFocus(); onCurrentDirectoryChanged(ANIM_NONE); return true; } @Override public boolean onQueryTextChange(String newText) { return false; } }); searchMenu.setOnActionExpandListener(new OnActionExpandListener() { @Override public boolean onMenuItemActionExpand(MenuItem item) { return true; } @Override public boolean onMenuItemActionCollapse(MenuItem item) { if (mIgnoreNextCollapse) { mIgnoreNextCollapse = false; return true; } mState.currentSearch = null; onCurrentDirectoryChanged(ANIM_NONE); return true; } }); mSearchView.setOnCloseListener(new SearchView.OnCloseListener() { @Override public boolean onClose() { if (mIgnoreNextClose) { mIgnoreNextClose = false; return false; } mState.currentSearch = null; onCurrentDirectoryChanged(ANIM_NONE); return false; } }); return true; }
From source file:dev.memento.MementoBrowser.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); // Only enable the "List" menu if there are Memento dates to display MenuItem item = menu.findItem(R.id.menu_list); item.setEnabled(mMementos.size() != 0); // Only enable "Return to Present" if we are not viewing the present item = menu.findItem(R.id.menu_off); item.setEnabled(!mToday.equalsDate(mDateChosen)); return true;//from w w w . j a va 2 s. c om }