List of usage examples for android.view MenuItem setIcon
public MenuItem setIcon(@DrawableRes int iconRes);
From source file:com.patloew.countries.ui.detail.DetailActivity.java
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); activityComponent().inject(this); setAndBindContentView(R.layout.activity_detail, savedInstanceState); setSupportActionBar(binding.toolbar); getSupportActionBar().setTitle(R.string.toolbar_title_detail); getSupportActionBar().setDisplayHomeAsUpEnabled(true); viewModel.update(Parcels.unwrap(getIntent().getParcelableExtra(Navigator.EXTRA_ARGS)), false); viewModel.addOnPropertyChangedCallback(new Observable.OnPropertyChangedCallback() { @Override// w w w . ja v a2s. co m public void onPropertyChanged(Observable observable, int propertyId) { if (propertyId == BR.bookmarkDrawable && menu != null) { MenuItem favoriteItem = menu.findItem(R.id.menu_item_favorite); favoriteItem.setIcon(viewModel.getBookmarkDrawable()); tintMenuIcon(favoriteItem); } } }); }
From source file:net.sakuramilk.kbcupdater.MainFragmentActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { menu.add("Update list"); MenuItem actionItem = menu.add("Update list"); actionItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); actionItem.setIcon(android.R.drawable.ic_menu_manage); return true;// w w w. j a va 2s. co m }
From source file:com.android.calculator2.StoreActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); MenuItem info = menu.findItem(R.id.info); info.setIcon( Theme.isLightTheme(getContext()) ? R.drawable.action_about_grey : R.drawable.action_about_white); return true;//from www. ja v a2 s . c om }
From source file:de.grobox.transportr.favorites.trips.FavoriteTripPopupMenu.java
private void setFavState(MenuItem item, boolean is_fav) { if (is_fav) { item.setTitle(R.string.action_unfav_trip); item.setIcon(R.drawable.ic_action_star_empty); DrawableCompat.setTint(item.getIcon(), iconColor); } else {//from w ww. j a v a 2s . c o m item.setTitle(R.string.action_fav_trip); item.setIcon(R.drawable.ic_action_star); DrawableCompat.setTint(item.getIcon(), iconColor); } }
From source file:com.patloew.countries.ui.detail.DetailActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_details, menu); this.menu = menu; MenuItem favoriteItem = menu.findItem(R.id.menu_item_favorite); MenuItem mapItem = menu.findItem(R.id.menu_item_maps); favoriteItem.setIcon(viewModel.getBookmarkDrawable()); tintMenuIcon(favoriteItem);/* ww w . j a v a 2s . c om*/ tintMenuIcon(mapItem); return super.onCreateOptionsMenu(menu); }
From source file:butter.droid.activities.base.ButterBaseActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); getMenuInflater().inflate(R.menu.activity_base, menu); BeamManager beamManager = BeamManager.getInstance(this); Boolean castingVisible = mShowCasting && beamManager.hasCastDevices(); MenuItem item = menu.findItem(R.id.action_casting); item.setVisible(castingVisible);/* w ww . j ava 2 s . co m*/ item.setIcon( beamManager.isConnected() ? R.drawable.ic_av_beam_connected : R.drawable.ic_av_beam_disconnected); return true; }
From source file:gov.wa.wsdot.android.wsdot.ui.FerriesRouteSchedulesDaySailingsActivity.java
private void toggleStar(MenuItem item) { resolver = getContentResolver();//from ww w .j a va 2 s . co m if (mIsStarred) { item.setIcon(R.drawable.ic_menu_star); try { ContentValues values = new ContentValues(); values.put(FerriesSchedules.FERRIES_SCHEDULE_IS_STARRED, 0); resolver.update(FerriesSchedules.CONTENT_URI, values, FerriesSchedules.FERRIES_SCHEDULE_ID + "=?", new String[] { Integer.toString(mId) }); Toast.makeText(this, R.string.remove_favorite, Toast.LENGTH_SHORT).show(); mIsStarred = false; } catch (Exception e) { Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show(); Log.e("FerriesRouteSchedulesDaySailingsActivity", "Error: " + e.getMessage()); } } else { item.setIcon(R.drawable.ic_menu_star_on); try { ContentValues values = new ContentValues(); values.put(FerriesSchedules.FERRIES_SCHEDULE_IS_STARRED, 1); resolver.update(FerriesSchedules.CONTENT_URI, values, FerriesSchedules.FERRIES_SCHEDULE_ID + "=?", new String[] { Integer.toString(mId) }); Toast.makeText(this, R.string.add_favorite, Toast.LENGTH_SHORT).show(); mIsStarred = true; } catch (Exception e) { Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show(); Log.e("FerriesRouteSchedulesDaySailingsActivity", "Error: " + e.getMessage()); } } }
From source file:com.jameswolfeoliver.pigeon.Utilities.DrawableHelper.java
public void applyTo(@NonNull MenuItem menuItem) { if (mWrappedDrawable == null) { throw new NullPointerException(); }//from w ww. j a v a 2 s . c o m menuItem.setIcon(mWrappedDrawable); }
From source file:cf.obsessiveorange.rhcareerfairlayout.ui.fragments.VPFiltersFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); MenuItem searchBtn = menu.findItem(R.id.action_search); searchBtn.setVisible(false);//from www.ja va2 s.co m ((MainActivity) getActivity()).closeSearch(); MenuItem clearFiltersItem = menu.add(getResources().getString(R.string.btn_clear_filters)); clearFiltersItem.setIcon(new IconDrawable(this.getActivity(), Iconify.IconValue.fa_times) .colorRes(R.color.accentNoTransparency).actionBarSize()); clearFiltersItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); clearFiltersItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { Toast.makeText(getActivity(), "Filters cleared", Toast.LENGTH_SHORT).show(); try { DBManager.setAllCategoriesSelected(false); } catch (SQLException e) { e.printStackTrace(); } ((FiltersCellAdapter) recyclerView.getAdapter()).refreshData(); synchronized (RHCareerFairLayout.refreshCompaniesNotifier) { RHCareerFairLayout.refreshCompaniesNotifier.notifyChanged(); } getActivity().runOnUiThread(new Runnable() { @Override public void run() { recyclerView.getAdapter().notifyDataSetChanged(); } }); return true; } }); }
From source file:net.sourceforge.servestream.activity.OrganizeUrlsActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); TypedArray drawables = obtainStyledAttributes(new int[] { R.attr.navigation_accept }); MenuItem item = menu.add(Menu.NONE, MENU_ID_ACCEPT, Menu.NONE, R.string.confirm_label); item.setIcon(drawables.getDrawable(0)); MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT); return true;/*w w w . j av a 2 s. c om*/ }