Example usage for android.view MenuItem getIcon

List of usage examples for android.view MenuItem getIcon

Introduction

In this page you can find the example usage for android.view MenuItem getIcon.

Prototype

public Drawable getIcon();

Source Link

Document

Returns the icon for this item as a Drawable (getting it from resources if it hasn't been loaded before).

Usage

From source file:org.mariotaku.twidere.util.ThemeUtils.java

public static void wrapMenuItemIcon(@NonNull MenuItem item, int itemColor, int... excludeGroups) {
    if (ArrayUtils.contains(excludeGroups, item.getGroupId()))
        return;//  w  w  w .  jav a2  s  .  c  o m
    final Drawable icon = item.getIcon();
    if (icon == null)
        return;
    if (icon instanceof ActionIconDrawable) {
        ((ActionIconDrawable) icon).setDefaultColor(itemColor);
        item.setIcon(icon);
        return;
    }
    icon.mutate();
    final Drawable.Callback callback = icon.getCallback();
    final ActionIconDrawable newIcon = new ActionIconDrawable(icon, itemColor);
    newIcon.setCallback(callback);
    item.setIcon(newIcon);
}

From source file:net.wespot.pim.compat.view.InqDataCollectionTaskCompatFragment.java

public void setEnabledDisabled(MenuItem item, boolean shouldBeEnabled) {
    if (shouldBeEnabled) {
        item.setEnabled(true);/*  w  w  w  . ja v  a 2  s  . co m*/
        item.getIcon().setAlpha(255);
    } else {
        // disabled
        item.setEnabled(false);
        item.getIcon().setAlpha(130);
    }
}

From source file:com.coinblesk.client.TransactionDetailActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.tx_detail_menu, menu);
    MenuItem openItem = menu.findItem(R.id.action_tx_open_web);
    openItem.setIcon(UIUtils.tintIconWhite(openItem.getIcon(), this));

    return true;//  www .  j av a2 s  . c o  m
}

From source file:net.wespot.pim.view.InqDataCollectionTaskFragment.java

public void setEnabledDisabled(MenuItem item, boolean shouldBeEnabled) {
    if (shouldBeEnabled) {
        item.setEnabled(true);//w  ww  .j a  v a 2  s. c  om
        item.getIcon().setAlpha(255);
    } else {
        item.setEnabled(false);
        item.getIcon().setAlpha(130);
    }
}

From source file:com.example.tj.weather.WeatherActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the toolbar/actionbar, if it is present.
    getMenuInflater().inflate(R.menu.menu_main, menu);

    MenuItem searchItem = menu.findItem(R.id.city_search);
    Drawable searchIcon = searchItem.getIcon();
    searchIcon.mutate().setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_IN);
    searchItem.setIcon(searchIcon);/*from w ww  . ja v  a 2 s. c  o m*/

    MenuItem locationSearchItem = menu.findItem(R.id.location_search);
    Drawable locationSearchIcon = locationSearchItem.getIcon();
    locationSearchIcon.mutate().setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_IN);
    searchItem.setIcon(searchIcon);

    return true;
}

From source file:com.joaquimley.faboptions.FabOptions.java

private void addButton(Context context, MenuItem menuItem) {
    AppCompatImageView button = mButtonContainer.addButton(context, menuItem.getItemId(), menuItem.getTitle(),
            menuItem.getIcon());
    button.setOnClickListener(this);
}

From source file:com.android.calendar.SearchActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.search_title_bar, menu);

    // replace the default top layer drawable of the today icon with a custom drawable
    // that shows the day of the month of today
    MenuItem menuItem = menu.findItem(R.id.action_today);
    if (Utils.isJellybeanOrLater()) {
        LayerDrawable icon = (LayerDrawable) menuItem.getIcon();
        Utils.setTodayIcon(icon, this, Utils.getTimeZone(SearchActivity.this, mTimeChangesUpdater));
    } else {/*from  www. j  a va2s. c  om*/
        menuItem.setIcon(R.drawable.ic_menu_today_no_date_holo_light);
    }

    MenuItem item = menu.findItem(R.id.action_search);

    MenuItemCompat.expandActionView(item);
    MenuItemCompat.setOnActionExpandListener(item, this);
    mSearchView = (SearchView) MenuItemCompat.getActionView(item);
    Utils.setUpSearchView(mSearchView, this);
    mSearchView.setQuery(mQuery, false);
    mSearchView.clearFocus();

    return true;
}

From source file:com.xandy.calendar.SearchActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.search_title_bar, menu);

    // replace the default top layer drawable of the today icon with a custom drawable
    // that shows the day of the month of today
    MenuItem menuItem = menu.findItem(R.id.action_today);
    if (Utils.isJellybeanOrLater()) {
        LayerDrawable icon = (LayerDrawable) menuItem.getIcon();
        Utils.setTodayIcon(icon, this, Utils.getTimeZone(SearchActivity.this, mTimeChangesUpdater));
    } else {//w  w  w.ja  v a2s  .c  o m
        menuItem.setIcon(R.drawable.ic_menu_today_no_date_holo_light);
    }

    MenuItem item = menu.findItem(R.id.action_search);
    item.expandActionView();
    item.setOnActionExpandListener(this);
    mSearchView = (SearchView) item.getActionView();
    Utils.setUpSearchView(mSearchView, this);
    mSearchView.setQuery(mQuery, false);
    mSearchView.clearFocus();

    return true;
}

From source file:com.crazymin2.retailstore.ui.BaseActivity.java

protected void showRedBadgeCounter(int count) {
    // Get the notifications MenuItem and LayerDrawable (layer-list)
    MenuItem item = menu.findItem(R.id.menu_cart);
    LayerDrawable icon = (LayerDrawable) item.getIcon();
    // Update LayerDrawable's MenuCounterDrawable
    setBadgeCount(this, icon, count/*DatabaseManager.getInstance().getProductCount()*/);
}

From source file:org.voidsink.anewjkuapp.fragment.CalendarFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.calendar, menu);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        MenuItem menuItem = menu.findItem(R.id.action_cal_goto_today);
        // replace the default top layer drawable of the today icon with a
        // custom drawable that shows the day of the month of today
        LayerDrawable icon = (LayerDrawable) menuItem.getIcon();
        UIUtils.setTodayIcon(icon, getContext(), "");
    }/*from   ww  w  . j  a  v  a2s  .  c  om*/
}