List of usage examples for android.view MenuItem setIcon
public MenuItem setIcon(@DrawableRes int iconRes);
From source file:com.weebly.opus1269.copyeverywhere.ui.main.MainActivity.java
private void setPrefFavFilter(boolean prefFavFilter, boolean restart) { mFavFilter = prefFavFilter;//from w ww . j av a 2 s .co m if (mMenu != null) { final MenuItem item = mMenu.findItem(R.id.action_fav_filter); item.setIcon(mFavFilter ? R.drawable.ic_favorite_24dp : R.drawable.ic_favorite_outline_24dp); item.setTitle(mFavFilter ? R.string.action_show_all : R.string.action_show_favs); final int color = ContextCompat.getColor(this, R.color.icons); final int alpha = 255; MenuTint.colorMenuItem(item, color, alpha); } if (restart) { getSupportLoaderManager().restartLoader(0, null, this); } }
From source file:com.hybris.mobile.activity.StoreLocatorDetailActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { // Clicking on the geofence icon case R.id.geofence_store: // If the geofence functionnality is not activated we display an error message if (!Hybris.isGeofencingActivated()) { Toast.makeText(this, R.string.error_geofence_not_activated, Toast.LENGTH_LONG); } else {/*from ww w. j a va2s .c om*/ // If the geofence is already activated for that store, clicking on it will disable the geofence if (geofenceJsonSharedPreferences.getGeofenceObject(store.getName()) != null) { item.setIcon(R.drawable.ic_menu_location_default); enableGeofence(false); } // In the other case we activate it else { item.setIcon(R.drawable.ic_menu_location_active); enableGeofence(true); } } return true; default: return false; } }
From source file:com.odoo.addons.calendar.CalendarDashboard.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { menu.clear();/*from w w w . ja va 2s .c o m*/ inflater.inflate(R.menu.menu_calendar_dashboard, menu); if (getActivity() != null) { MenuItem today = menu.findItem(R.id.menu_dashboard_goto_today); today.setIcon(TodayIcon.get(getActivity()).getIcon()); } setHasSearchView(this, menu, R.id.menu_search); }
From source file:org.libreoffice.ui.LibreOfficeUIActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.view_menu, menu); MenuItem item = menu.findItem(R.id.menu_view_toggle); if (viewMode == GRID_VIEW) { item.setTitle(R.string.list_view); item.setIcon(R.drawable.light_view_as_list); } else {//from w ww . j av a 2 s . c o m item.setTitle(R.string.grid_view); item.setIcon(R.drawable.light_view_as_grid); } item = menu.findItem(R.id.menu_sort_size); if (sortMode == FileUtilities.SORT_LARGEST) { item.setTitle(R.string.sort_smallest); } else { item.setTitle(R.string.sort_largest); } item = menu.findItem(R.id.menu_sort_az); if (sortMode == FileUtilities.SORT_AZ) { item.setTitle(R.string.sort_za); } else { item.setTitle(R.string.sort_az); } item = menu.findItem(R.id.menu_sort_modified); if (sortMode == FileUtilities.SORT_NEWEST) { item.setTitle(R.string.sort_oldest); } else { item.setTitle(R.string.sort_newest); } return true; }
From source file:com.jecelyin.editor.v2.ui.MainActivity.java
/** * * @param menuResId/*from w ww. java 2s . c o m*/ * @param status {@link com.jecelyin.editor.v2.view.menu.MenuDef#STATUS_NORMAL}, {@link com.jecelyin.editor.v2.view.menu.MenuDef#STATUS_DISABLED} */ public void setMenuStatus(@IdRes int menuResId, int status) { MenuItem menuItem = mToolbar.getMenu().findItem(menuResId); if (menuItem == null) { throw new RuntimeException("Can't find a menu item"); } Drawable icon = menuItem.getIcon(); if (status == MenuDef.STATUS_DISABLED) { menuItem.setEnabled(false); menuItem.setIcon(MenuManager.makeToolbarDisabledIcon(icon)); } else { menuItem.setEnabled(true); if (menuItem.getGroupId() == MenuDef.GROUP_TOOLBAR) { menuItem.setIcon(MenuManager.makeToolbarNormalIcon(icon)); } else { menuItem.setIcon(MenuManager.makeMenuNormalIcon(icon)); } } }
From source file:br.com.brolam.cloudvision.ui.NoteVisionActivity.java
/** * Atualizar item note_vision_keyboard_or_camera no menu do toolbar. * @param onKeyboard//w w w .j a va 2s .c o m */ private void setMenuItemNoteVisionKeyboardOrCamera(boolean onKeyboard) { MenuItem menuItemNoteVision = toolbar.getMenu().findItem(R.id.note_vision_keyboard_or_camera); if (onKeyboard) { if (menuItemNoteVision != null) { menuItemNoteVision.setIcon(R.drawable.ic_on_camera_white).setTitle(R.string.note_vision_camera_on); } } else { if (menuItemNoteVision != null) { menuItemNoteVision.setIcon(R.drawable.ic_on_keyboard_white) .setTitle(R.string.note_vision_keyboard_on); } showOrHideFabAdd(); } }
From source file:org.openremote.android.console.GroupActivity.java
/** * If there have global or local tabbar, create and update menu before the menu is shown. * //w w w .j a v a 2 s . c o m * @see android.app.Activity#onPrepareOptionsMenu(android.view.Menu) */ @Override public boolean onPrepareOptionsMenu(Menu menu) { if (currentGroupView == null || currentGroupView.getGroup() == null) { return true; } TabBar tabBar = currentGroupView.getGroup().getTabBar(); if (tabBar == null) { tabBar = XMLEntityDataBase.globalTabBar; } if (tabBar != null && tabBar.getTabBarItems().size() > 0) { menu.clear(); ArrayList<TabBarItem> items = tabBar.getTabBarItems(); int itemSize = items.size(); for (int i = 0; i < itemSize; i++) { MenuItem menuItem = menu.add(0, i, i, items.get(i).getName()); if (items.get(i).getImage() != null) { menuItem.setIcon(ImageUtil .createFromPathQuietly(Constants.FILE_FOLDER_PATH + items.get(i).getImage().getSrc())); } final Navigate navigate = items.get(i).getNavigate(); if (navigate != null) { menuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { handleNavigate(navigate); return true; } }); } } } return true; }
From source file:es.uniovi.imovil.fcrtrainer.BaseExerciseFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); inflater.inflate(R.menu.game_control, menu); MenuItem item = menu.findItem(R.id.action_change_game_mode); try {/*from www .ja v a 2 s.c o m*/ MainActivity activity = (MainActivity) getActivity(); if (item != null && activity != null) { item.setVisible(!activity.isDrawerOpen()); } } catch (ClassCastException ex) { // El fragmento est incrustado en una actividad distinta a // MainActivity. No se hace nada } MenuItem setup = menu.findItem(R.id.action_settings); if (mIsPlaying) { item.setIcon(R.drawable.ic_action_stop); setup.setVisible(false); } else { item.setIcon(R.drawable.ic_action_play); setup.setVisible(true); } }
From source file:me.acristoffers.tracker.activities.PackageListActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { final int id = item.getItemId(); switch (id) { case R.id.check_for_updates: packageListFragment.checkForUpdates(); return true; case R.id.toggle_inactive: final boolean showInactive = packageListFragment.toggleShowInactive(); item.setTitle(showInactive ? R.string.hide_inactive : R.string.show_inactive); item.setIcon( showInactive ? R.drawable.ic_visibility_off_black_48dp : R.drawable.ic_visibility_black_48dp); return true; case R.id.about: about();//from ww w . j av a2 s. c om return true; case R.id.settings: final Intent intent = new Intent(this, PreferencesActivity.class); startActivity(intent); return true; default: return super.onOptionsItemSelected(item); } }
From source file:com.cerema.cloud2.ui.fragment.OCFileListFragment.java
private void changeGridIcon(Menu menu) { MenuItem menuItem = menu.findItem(R.id.action_switch_view); if (isGridViewPreferred(mFile)) { menuItem.setTitle(getString(R.string.action_switch_list_view)); menuItem.setIcon(R.drawable.ic_view_list); } else {//from w w w . j a va 2s .co m menuItem.setTitle(getString(R.string.action_switch_grid_view)); menuItem.setIcon(R.drawable.ic_view_module); } }