List of usage examples for android.view MenuItem setIcon
public MenuItem setIcon(@DrawableRes int iconRes);
From source file:org.jamienicol.episodes.ShowActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { final MenuItem toggleStarred = menu.findItem(R.id.menu_toggle_show_starred); if (isShowStarred) { toggleStarred.setIcon(R.drawable.ic_show_starred); toggleStarred.setTitle(R.string.menu_unstar_show); } else {//from ww w . j a v a 2 s.co m toggleStarred.setIcon(R.drawable.ic_show_unstarred); toggleStarred.setTitle(R.string.menu_star_show); } final MenuItem toggleArchived = menu.findItem(R.id.menu_toggle_show_archived); if (isShowArchived) { toggleArchived.setIcon(R.drawable.ic_shows_list_archived); toggleArchived.setTitle(R.string.menu_unarchive_show); } else { toggleArchived.setIcon(R.drawable.ic_shows_list_unarchived); toggleArchived.setTitle(R.string.menu_archive_show); } return super.onPrepareOptionsMenu(menu); }
From source file:org.tomasdavid.vehicleroutingproblem.fragments.VrpFragment.java
/** * {@inheritDoc}/*from www.j a v a 2 s . c om*/ */ @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.menu_vrp, menu); // according to solver task status change play/ stop icon MenuItem playStopButton = menu.findItem(R.id.action_run); if (vrpSolverTask.isRunning()) { playStopButton.setIcon(R.drawable.ic_stop_white_24dp); } else { playStopButton.setIcon(R.drawable.ic_play_arrow_white_24dp); } super.onCreateOptionsMenu(menu, inflater); }
From source file:com.mifos.mifosxdroid.online.documentlist.DocumentListFragment.java
@Override public void onPrepareOptionsMenu(Menu menu) { menu.clear();/*from w ww. j ava 2s . co m*/ MenuItem menuItemAddNewDocument = menu.add(Menu.NONE, MENU_ITEM_ADD_NEW_DOCUMENT, Menu.NONE, getString(R.string.add_new)); menuItemAddNewDocument.setIcon(ContextCompat.getDrawable(getActivity(), R.drawable.ic_add_white_24dp)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) menuItemAddNewDocument.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); super.onPrepareOptionsMenu(menu); }
From source file:de.tap.easy_xkcd.fragments.comics.OfflineFragment.java
/************************* * Favorite Modification/* w w w. j ava 2 s. c o m*/ ************************/ private boolean ModifyFavorites(MenuItem item) { if (databaseManager.checkFavorite(lastComicNumber)) { new DeleteComicImageTask().execute(false); item.setIcon(R.drawable.ic_favorite_outline); } else { //save image to internal storage new SaveComicImageTask().execute(false); item.setIcon(R.drawable.ic_action_favorite); } return true; }
From source file:net.amdroid.metrosp.MetroSP.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); menu.add(0, MENU_PREFS, 0, getResources().getText(R.string.preferences)); MenuItem item = menu.findItem(MENU_PREFS); item.setIcon(R.drawable.ic_menu_preferences); return true;// w w w . ja v a2s . c o m }
From source file:fr.simon.marquis.preferencesmanager.ui.AppListActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { boolean show = Utils.isShowSystemApps(this); MenuItem showItem = menu.findItem(R.id.show_system_apps); if (showItem != null) { showItem.setTitle(show ? R.string.hide_system_apps : R.string.show_system_apps); showItem.setIcon(show ? R.drawable.ic_action_show : R.drawable.ic_action_hide); }//from w w w . j a v a2s.c o m MenuItem themeItem = menu.findItem(R.id.switch_theme); if (themeItem != null) { themeItem.setTitle(App.theme.title); } return super.onPrepareOptionsMenu(menu); }
From source file:com.bill.metrobus.FriendsList.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { // Place an action bar item for searching. MenuItem item = menu.add("Search"); item.setIcon(android.R.drawable.ic_menu_search); MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS | MenuItemCompat.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW); final View searchView = SearchViewCompat.newSearchView(getActivity()); if (searchView != null) { SearchViewCompat.setOnQueryTextListener(searchView, new OnQueryTextListenerCompat() { @Override//from ww w .j a v a2s. com public boolean onQueryTextChange(String newText) { // Called when the action bar search text has // changed. Update // the search filter, and restart the loader to do a // new query // with this filter. String newFilter = !TextUtils.isEmpty(newText) ? newText : null; // Don't do anything if the filter hasn't actually // changed. // Prevents restarting the loader when restoring // state. if (mCurFilter == null && newFilter == null) { return true; } if (mCurFilter != null && mCurFilter.equals(newFilter)) { return true; } mCurFilter = newFilter; // getLoaderManager().restartLoader(0, null, // FriendsList.this); return true; } }); SearchViewCompat.setOnCloseListener(searchView, new OnCloseListenerCompat() { @Override public boolean onClose() { if (!TextUtils.isEmpty(SearchViewCompat.getQuery(searchView))) { SearchViewCompat.setQuery(searchView, null, true); } return true; } }); MenuItemCompat.setActionView(item, searchView); } }
From source file:com.stoyanr.feeder.activity.ItemsActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); getMenuInflater().inflate(R.menu.items_menu, menu); MenuUtils.setShowAsActionAll(menu);//from w ww .ja va2s. co m MenuItem item = menu.findItem(R.id.view_featured); item.setChecked(featuredOnly); int iconRes = featuredOnly ? R.drawable.btn_check_on : R.drawable.btn_check_off; item.setIcon(iconRes); if (prevChannelId < 0) { menu.removeItem(R.id.prev_channel); } if (nextChannelId < 0) { menu.removeItem(R.id.next_channel); } return true; }
From source file:com.osama.cryptofm.filemanager.ui.TabsFragmentOne.java
public void toggleLayout(MenuItem item) { Log.d(TAG, "toggleLayout: Changing layout"); if (item.getItemId() == R.id.items_view_menu_item) { if (mRecyclerView.getLayoutManager() == mGridLayoutManager) { item.setIcon(mContext.getDrawable(R.drawable.ic_grid_view)); if (mLinearLayoutManager == null) { mLinearLayoutManager = new LinearLayoutManager(mContext); }//from ww w .j ava 2s . c om mHelper.attachToRecyclerView(mRecyclerView); mRecyclerView.setLayoutManager(mLinearLayoutManager); new SharedPreferencesTask().execute(true); } else { item.setIcon(mContext.getDrawable(R.drawable.ic_items_view)); if (mGridLayoutManager == null) { mGridLayoutManager = new GridLayoutManager(mContext, 2); } mHelper.attachToRecyclerView(null); mRecyclerView.setLayoutManager(mGridLayoutManager); new SharedPreferencesTask().execute(false); } mRecyclerView.requestLayout(); } }
From source file:ro.expectations.expenses.ui.categories.EditCategoryFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { MenuItem item = menu.add(Menu.NONE, R.id.action_save, Menu.NONE, R.string.action_save); item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); item.setIcon(DrawableHelper.tint(getActivity(), R.drawable.ic_done_black_24dp, R.color.colorWhite)); super.onCreateOptionsMenu(menu, inflater); }