List of usage examples for android.view MenuItem setVisible
public MenuItem setVisible(boolean visible);
From source file:com.money.manager.ex.common.AllDataListFragment.java
/** * Add options to the action bar of the host activity. * This is not called in ActionBar Activity, i.e. Search. * @param menu/*from w w w. j av a 2 s . co m*/ * @param inflater */ @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); Activity activity = getActivity(); if (activity == null) return; MenuItem itemExportToCsv = menu.findItem(R.id.menu_export_to_csv); if (itemExportToCsv != null) itemExportToCsv.setVisible(true); MenuItem itemSearch = menu.findItem(R.id.menu_search_transaction); if (itemSearch != null) { itemSearch .setVisible(!activity.getClass().getSimpleName().equals(SearchActivity.class.getSimpleName())); } // show this on all transactions lists later? // show this menu only when on Search Activity for now. if (activity.getClass().getSimpleName().equals(SearchActivity.class.getSimpleName())) { // Add default menu options. todo: check why this is executed twice. // Includes menu item for .qif export MenuItem qifExport = menu.findItem(R.id.menu_qif_export); if (qifExport == null) { inflater.inflate(R.menu.menu_alldata_operations, menu); } } }
From source file:com.piusvelte.webcaster.MainActivity.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.main, menu); MenuItem mediaRouteItem = menu.findItem(R.id.action_mediaroute); if (mediaRouteSelector != null) { mediaRouteButton = (MediaRouteButton) mediaRouteItem.getActionView(); mediaRouteButton.setRouteSelector(mediaRouteSelector); mediaRouteButton.setDialogFactory(new MediaRouteDialogFactory()); mediaRouteItem.setVisible(true); mediaRouteItem.setEnabled(true); } else {/*from w w w . j ava 2s . c o m*/ mediaRouteItem.setVisible(false); mediaRouteItem.setEnabled(false); } return true; }
From source file:com.nadmm.airports.ActivityBase.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.mainmenu, menu); MenuItem settingsItem = menu.findItem(R.id.menu_settings); settingsItem.setVisible(getSelfNavDrawerItem() == NAVDRAWER_ITEM_INVALID); MenuItem searchItem = menu.findItem(R.id.menu_search); SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setIconifiedByDefault(false); return super.onCreateOptionsMenu(menu); }
From source file:com.gelakinetic.mtgfam.fragments.LifeCounterFragment.java
/** * If TTS is not initialized, remove it from the menu. If it is initialized, show it. * * @param menu The menu to show or hide the "announce life totals" button in. */// w w w . ja v a 2 s . c om @Override public void onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); MenuItem menuItem = menu.findItem(R.id.announce_life); assert menuItem != null; if (!mTtsInit || getFamiliarActivity() == null || !getFamiliarActivity().mIsMenuVisible) { menuItem.setVisible(false); } else { menuItem.setVisible(true); } }
From source file:com.mobicage.rogerthat.plugins.messaging.FriendsThreadActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { for (int i = 0; i < menu.size(); i++) { MenuItem item = menu.getItem(i); switch (item.getItemId()) { case R.id.members: item.setVisible(!SystemUtils.isFlagEnabled(mFlags, MessagingPlugin.FLAG_DYNAMIC_CHAT)); break; case R.id.delete_conversation: item.setVisible(!SystemUtils.isFlagEnabled(mFlags, MessagingPlugin.FLAG_NOT_REMOVABLE)); break; case R.id.info: item.setVisible(SystemUtils.isFlagEnabled(mFlags, MessagingPlugin.FLAG_DYNAMIC_CHAT)); break; }//from www. j a v a2 s . c o m } return true; }
From source file:org.cobaltians.cobalt.activities.CobaltActivity.java
public void setActionItemVisible(String actionName, boolean visible) { MenuItem menuItem = mMenuItemByNameMap.get(actionName); if (menuItem != null) { menuItem.setVisible(visible); }//from w w w. j ava 2s .co m }
From source file:de.enlightened.peris.CategoriesFragment.java
@Override public final void onPrepareOptionsMenu(final Menu menu) { super.onPrepareOptionsMenu(menu); if ((this.userid != null) && (menu != null)) { if (this.subforumId == null || this.subforumId.contentEquals("participated") || this.subforumId.contentEquals("favs") || this.subforumId.contentEquals("search")) { final MenuItem item = menu.findItem(R.id.cat_mark_read); if (item != null) { item.setVisible(false); }/*from w w w . j a v a2s . c o m*/ } else { final MenuItem item = menu.findItem(R.id.cat_mark_read); if (item != null) { if (ThemeSetter.getForegroundDark(this.background)) { item.setIcon(R.drawable.ic_action_read_dark); } } } if (this.subforumId == null || this.subforumId.contentEquals("participated") || this.subforumId.contentEquals("favs") || this.subforumId.contentEquals("userrecent") || this.subforumId.contentEquals("search")) { final MenuItem item2 = menu.findItem(R.id.cat_new_thread); if (item2 != null) { item2.setVisible(false); } } else { final MenuItem item2 = menu.findItem(R.id.cat_new_thread); if (item2 != null) { if (ThemeSetter.getForegroundDark(this.background)) { item2.setIcon(R.drawable.ic_action_new_dark); } } } final MenuItem browserItem = menu.findItem(R.id.cat_open_browser); if (this.shareURL == null) { browserItem.setVisible(false); } else { browserItem.setVisible(true); } } }
From source file:com.cssweb.android.base.DialogActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { if (activityKind == Global.QUOTE_USERSTK) { MenuItem localMenuItem1 = menu.findItem(R.id.zr_hq_mystock); MenuItem localMenuItem2 = menu.findItem(R.id.zr_hq_addstock); MenuItem localMenuItem3 = menu.findItem(R.id.zr_hq_fundtrade); MenuItem localMenuItem4 = menu.findItem(R.id.zr_hq_gugle); MenuItem localMenuItem5 = menu.findItem(R.id.zr_hq_chicang); if (localMenuItem1 != null) localMenuItem1.setVisible(false); if (localMenuItem2 != null) localMenuItem2.setVisible(false); if (localMenuItem3 != null) localMenuItem3.setVisible(false); if (localMenuItem4 != null) localMenuItem4.setVisible(false); if (localMenuItem5 != null) localMenuItem5.setVisible(true); } else if (activityKind == Global.QUOTE_STOCK || activityKind == Global.QUOTE_BOND || activityKind == Global.QUOTE_MONETARY || activityKind == Global.QUOTE_MIX) { MenuItem localMenuItem1 = menu.findItem(R.id.zr_hq_mystock_set); MenuItem localMenuItem2 = menu.findItem(R.id.zr_hq_remove); MenuItem localMenuItem3 = menu.findItem(R.id.zr_hq_quickbuy); MenuItem localMenuItem4 = menu.findItem(R.id.zr_hq_quicksale); MenuItem localMenuItem5 = menu.findItem(R.id.zr_hq_revocation); MenuItem localMenuItem6 = menu.findItem(R.id.zr_hq_remove); MenuItem localMenuItem7 = menu.findItem(R.id.zr_hq_queryfund); if (localMenuItem1 != null) localMenuItem1.setVisible(false); if (localMenuItem2 != null) localMenuItem2.setVisible(false); if (localMenuItem3 != null) localMenuItem3.setVisible(false); if (localMenuItem4 != null) localMenuItem4.setVisible(false); if (localMenuItem5 != null) localMenuItem5.setVisible(false); if (localMenuItem6 != null) localMenuItem6.setVisible(false); if (localMenuItem7 != null) { localMenuItem7.setVisible(true); }//from w w w . ja v a2 s. c om } else if (activityKind == Global.SUN_PRIVATE) { MenuItem localMenuItem1 = menu.findItem(R.id.zr_hq_mystock_set); MenuItem localMenuItem2 = menu.findItem(R.id.zr_hq_remove); MenuItem localMenuItem3 = menu.findItem(R.id.zr_hq_quickbuy); MenuItem localMenuItem4 = menu.findItem(R.id.zr_hq_quicksale); MenuItem localMenuItem5 = menu.findItem(R.id.zr_hq_revocation); MenuItem localMenuItem6 = menu.findItem(R.id.zr_hq_remove); MenuItem localMenuItem7 = menu.findItem(R.id.zr_hq_addstock); MenuItem localMenuItem8 = menu.findItem(R.id.zr_hq_gugle); MenuItem localMenuItem9 = menu.findItem(R.id.zr_hq_queryfund); if (localMenuItem1 != null) localMenuItem1.setVisible(false); if (localMenuItem2 != null) localMenuItem2.setVisible(false); if (localMenuItem3 != null) localMenuItem3.setVisible(false); if (localMenuItem4 != null) localMenuItem4.setVisible(false); if (localMenuItem5 != null) localMenuItem5.setVisible(false); if (localMenuItem6 != null) localMenuItem6.setVisible(false); if (localMenuItem7 != null) localMenuItem7.setVisible(false); if (localMenuItem8 != null) localMenuItem8.setVisible(false); if (localMenuItem9 != null) localMenuItem9.setVisible(true); } else if (activityKind == Global.QUOTE_DAPAN || activityKind == Global.QUOTE_HSZS || activityKind == Global.HK_CYB || activityKind == Global.HK_MAINBOARD || activityKind == Global.ZJS || activityKind == Global.SDZ) { MenuItem localMenuItem1 = menu.findItem(R.id.zr_hq_mystock_set); MenuItem localMenuItem2 = menu.findItem(R.id.zr_hq_remove); MenuItem localMenuItem3 = menu.findItem(R.id.zr_hq_fundtrade); MenuItem localMenuItem4 = menu.findItem(R.id.zr_hq_gugle); MenuItem localMenuItem5 = menu.findItem(R.id.zr_hq_quickbuy); MenuItem localMenuItem6 = menu.findItem(R.id.zr_hq_quicksale); MenuItem localMenuItem7 = menu.findItem(R.id.zr_hq_revocation); if (localMenuItem1 != null) localMenuItem1.setVisible(false); if (localMenuItem2 != null) localMenuItem2.setVisible(false); if (localMenuItem3 != null) localMenuItem3.setVisible(false); if (localMenuItem4 != null) localMenuItem4.setVisible(false); if (localMenuItem5 != null) localMenuItem5.setVisible(false); if (localMenuItem6 != null) localMenuItem6.setVisible(false); if (localMenuItem7 != null) localMenuItem7.setVisible(false); } else { MenuItem localMenuItem1 = menu.findItem(R.id.zr_hq_mystock_set); MenuItem localMenuItem2 = menu.findItem(R.id.zr_hq_remove); MenuItem localMenuItem3 = menu.findItem(R.id.zr_hq_fundtrade); //MenuItem localMenuItem4 = menu.findItem(R.id.zr_hq_gugle); if (localMenuItem1 != null) localMenuItem1.setVisible(false); if (localMenuItem2 != null) localMenuItem2.setVisible(false); if (localMenuItem3 != null) localMenuItem3.setVisible(false); //if(localMenuItem4!=null) // localMenuItem4.setVisible(false); } return super.onPrepareOptionsMenu(menu); }
From source file:cgeo.geocaching.CacheListActivity.java
private static void setVisibleEnabled(final Menu menu, final int itemId, final boolean visible, final boolean enabled) { final MenuItem item = menu.findItem(itemId); item.setVisible(visible); item.setEnabled(enabled);//from www . j av a 2 s.c om }
From source file:com.nttec.everychan.ui.MainActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { MenuItem drawerMenuItem = menu.findItem(R.id.menu_open_close_drawer); if (drawerMenuItem != null) { drawerMenuItem.setTitle(drawerLayout.isDrawerOpen(DRAWER_GRAVITY) ? R.string.menu_close_drawer : R.string.menu_open_drawer); }//www. jav a 2 s. c o m MenuItem favoritesMenuItem = menu.findItem(R.id.menu_favorites); if (favoritesMenuItem != null && tabsAdapter != null && tabsAdapter.getSelectedItem() >= 0) { TabModel tab = tabsAdapter.getItem(tabsAdapter.getSelectedItem()); favoritesMenuItem .setTitle(isFavorite(tab) ? R.string.menu_remove_favorites : R.string.menu_add_favorites); } MenuItem preferencesMenuItem = menu.findItem(R.id.menu_settings); MenuItem preferencesSubMenuItem = menu.findItem(R.id.menu_sub_settings); try { if (MainApplication.getInstance().settings.preferencesSubmenu()) { preferencesSubMenuItem.setVisible(true); preferencesMenuItem.setVisible(false); Menu subMenu = preferencesSubMenuItem.getSubMenu(); subMenu.findItem(R.id.menu_sub_settings_suspend) .setVisible(MainApplication.getInstance().settings.isAutoupdateEnabled()); subMenu.findItem(R.id.menu_sub_settings_autoupdate) .setChecked(MainApplication.getInstance().settings.isAutoupdateEnabled()); subMenu.findItem(R.id.menu_sub_settings_maskpictures) .setChecked(MainApplication.getInstance().settings.maskPictures()); } else { preferencesMenuItem.setVisible(true); preferencesSubMenuItem.setVisible(false); } } catch (Exception e) { Logger.e(TAG, e); } return super.onPrepareOptionsMenu(menu); }