List of usage examples for android.view MenuItem setIcon
public MenuItem setIcon(@DrawableRes int iconRes);
From source file:com.andybotting.tramhunter.activity.StopDetailsActivity.java
/** * Create the options for a given menu/*from w ww . j a v a 2 s . c o m*/ */ @Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); menu.add(0, MENU_ITEM_REFRESH, 0, "Refresh"); MenuItem menuItem1 = menu.findItem(MENU_ITEM_REFRESH); menuItem1.setIcon(R.drawable.ic_menu_refresh); menu.add(0, MENU_ITEM_FAVOURITE, 0, ""); // Title set in onMenuOpened() MenuItem menuItem2 = menu.findItem(MENU_ITEM_FAVOURITE); menuItem2.setIcon(R.drawable.ic_menu_star); menu.add(0, MENU_ITEM_MAP, 0, "Map"); MenuItem menuItem3 = menu.findItem(MENU_ITEM_MAP); menuItem3.setIcon(R.drawable.ic_menu_mapmode); return true; }
From source file:org.amahi.anywhere.fragment.ServerFilesFragment.java
private void setUpFilesContentSortIcon(MenuItem menuItem) { switch (filesSort) { case NAME:/*from www. ja v a2 s . c om*/ menuItem.setIcon(R.drawable.ic_menu_sort_name); break; case MODIFICATION_TIME: menuItem.setIcon(R.drawable.ic_menu_sort_modification_time); break; default: break; } }
From source file:edu.berkeley.boinc.BOINCActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { if (Logging.DEBUG) Log.d(Logging.TAG, "BOINCActivity onPrepareOptionsMenu()"); // run mode, set title and icon based on status MenuItem runMode = menu.findItem(R.id.run_mode); if (clientComputingStatus == ClientStatus.COMPUTING_STATUS_NEVER) { // display play button runMode.setTitle(R.string.menu_run_mode_enable); runMode.setIcon(R.drawable.playw); } else {/*from www . ja v a 2s . co m*/ // display stop button runMode.setTitle(R.string.menu_run_mode_disable); runMode.setIcon(R.drawable.pausew); } return super.onPrepareOptionsMenu(menu); }
From source file:com.grarak.kerneladiutor.activities.NavigationActivity.java
private void appendFragments(boolean setShortcuts) { sActualFragments.clear();//from w w w .ja v a2 s . co m Menu menu = mNavigationView.getMenu(); menu.clear(); SubMenu lastSubMenu = null; for (NavigationFragment navigationFragment : sFragments) { Fragment fragment = navigationFragment.mFragment; int id = navigationFragment.mId; Drawable drawable = ContextCompat.getDrawable(this, Utils.DONATED && Prefs.getBoolean("section_icons", false, this) && navigationFragment.mDrawable != 0 ? navigationFragment.mDrawable : R.drawable.ic_blank); if (fragment == null) { lastSubMenu = menu.addSubMenu(id); sActualFragments.put(id, null); } else if (Prefs.getBoolean(fragment.getClass().getSimpleName() + "_enabled", true, this)) { MenuItem menuItem = lastSubMenu == null ? menu.add(0, id, 0, id) : lastSubMenu.add(0, id, 0, id); menuItem.setIcon(drawable); menuItem.setCheckable(true); if (mSelection != 0) { mNavigationView.setCheckedItem(mSelection); } sActualFragments.put(id, fragment); } } if (setShortcuts) { setShortcuts(); } }
From source file:org.dharmaseed.android.NavigationActivity.java
public void setStarButton() { int icon;/* w ww .ja va2 s.c o m*/ if (starFilterOn) { icon = getResources().getIdentifier("btn_star_big_on", "drawable", "android"); } else { icon = getResources().getIdentifier("btn_star_big_off", "drawable", "android"); } if (menu != null) { MenuItem starButton = menu.findItem(R.id.action_toggle_starred); starButton.setIcon(ContextCompat.getDrawable(this, icon)); } }
From source file:com.android.gallery3d.ingest.IngestActivity.java
private void setSwitcherMenuState(MenuItem menuItem, boolean inFullscreenMode) { if (menuItem == null) { return;//from w w w. jav a 2 s . co m } if (!inFullscreenMode) { menuItem.setIcon(android.R.drawable.ic_menu_zoom); menuItem.setTitle(R.string.ingest_switch_photo_fullscreen); } else { menuItem.setIcon(android.R.drawable.ic_dialog_dialer); menuItem.setTitle(R.string.ingest_switch_photo_grid); } }
From source file:com.conferenceengineer.android.iosched.ui.ScheduleFragment.java
@Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.sessions_context, menu); MenuItem starMenuItem = menu.findItem(R.id.menu_star); starMenuItem.setTitle(R.string.description_remove_schedule); starMenuItem.setIcon(R.drawable.ic_action_remove_schedule); mAdapter.notifyDataSetChanged();/*from w w w.ja v a2s . c o m*/ mActionModeStarted = true; return true; }
From source file:com.slownet5.pgprootexplorer.filemanager.ui.FileManagerActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { Log.d(TAG, "onPrepareOptionsMenu: preparing menu"); if (SharedData.IS_IN_COPY_MODE) { return super.onPrepareOptionsMenu(menu); }/* ww w. j a v a 2s.c om*/ MenuItem item = menu.getItem(0); if (SharedData.LINEAR_LAYOUTMANAGER) { item.setIcon(ContextCompat.getDrawable(this, R.drawable.ic_gridview)); } return true; }
From source file:ch.kanti_baden.pu_marc_14b.traffictimewaste.SORT_TYPE.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.menu_post_list, menu); // Disable create post button if user isn't logged in if (DatabaseLink.instance.isLoggedIn()) { MenuItem menuItem = menu.findItem(R.id.action_login); menuItem.setEnabled(false);/* ww w . j a v a 2 s . com*/ } else { MenuItem menuItem = menu.findItem(R.id.action_create); menuItem.setEnabled(false); Drawable icon = menuItem.getIcon(); icon.mutate().setColorFilter(Color.GRAY, PorterDuff.Mode.SRC_IN); menuItem.setIcon(icon); } // Get the SearchView and set the searchable configuration SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); final SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView(); searchView.setOnSearchClickListener(new View.OnClickListener() { @Override public void onClick(View v) { searchView.setTranslationX(500f); searchView.setAlpha(0f); searchView.animate().translationX(0); searchView.animate().alpha(1f); } }); // Assumes current activity is the searchable activity searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); return true; }
From source file:cc.softwarefactory.lokki.android.activities.MainActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { menu.clear();//from ww w .j a va 2 s . c o m if (mNavigationDrawerFragment != null && !mNavigationDrawerFragment.isDrawerOpen()) { if (selectedOption == 0) { // Map getMenuInflater().inflate(R.menu.map, menu); MenuItem menuItem = menu.findItem(R.id.action_visibility); if (menuItem != null) { Log.e(TAG, "onPrepareOptionsMenu - Visible: " + MainApplication.visible); if (MainApplication.visible) { menuItem.setIcon(R.drawable.ic_visible); } else { menuItem.setIcon(R.drawable.ic_invisible); } } } else if (selectedOption == 2) { // Contacts screen getMenuInflater().inflate(R.menu.contacts, menu); } else if (selectedOption == -10) { // Add contacts screen getMenuInflater().inflate(R.menu.add_contact, menu); } getMenuInflater().inflate(R.menu.main_activity_actions, menu); menu.findItem(R.id.action_logout).setVisible(true); } return super.onPrepareOptionsMenu(menu); }