Example usage for android.view MenuItem setIcon

List of usage examples for android.view MenuItem setIcon

Introduction

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

Prototype

public MenuItem setIcon(@DrawableRes int iconRes);

Source Link

Document

Change the icon associated with this item.

Usage

From source file:com.gbozza.android.stockhawk.ui.MainActivity.java

/**
 * Helper method to update the toolbar icon for the display of the main list
 *
 * @param item the MenuItem we have to change
 *///w  ww  .j  a va  2  s .  c o m
private void setDisplayModeMenuItemIcon(MenuItem item) {
    if (PrefUtils.getDisplayMode(this).equals(getString(R.string.pref_display_mode_absolute_key))) {
        item.setIcon(R.drawable.ic_percentage);
    } else {
        item.setIcon(R.drawable.ic_dollar);
    }
}

From source file:com.keylesspalace.tusky.ViewThreadActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.view_thread_toolbar, menu);
    MenuItem menuItem = menu.findItem(R.id.action_reveal);
    menuItem.setVisible(revealButtonState != REVEAL_BUTTON_HIDDEN);
    menuItem.setIcon(
            revealButtonState == REVEAL_BUTTON_REVEAL ? R.drawable.ic_eye_24dp : R.drawable.ic_hide_media_24dp);
    return super.onCreateOptionsMenu(menu);
}

From source file:org.strongswan.android.ui.TrustedCertificateListFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    MenuItem item = menu.add(R.string.search);
    item.setIcon(android.R.drawable.ic_menu_search);
    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

    SearchView sv = new SearchView(getActivity());
    sv.setOnQueryTextListener(this);
    item.setActionView(sv);//from w  ww . ja v  a2s . c  om
}

From source file:com.mifos.mifosxdroid.online.DataTableDataFragment.java

@SuppressWarnings("deprecation")
@Override/* w  w  w  . j av a2 s.  com*/
public void onPrepareOptionsMenu(Menu menu) {
    menu.clear();
    MenuItem menuItemAddNewEntryToDataTable = menu.add(Menu.NONE, MEUN_ITEM_ADD_NEW_ENTRY, Menu.NONE,
            getString(R.string.add_new));
    menuItemAddNewEntryToDataTable.setIcon(getResources().getDrawable(R.drawable.ic_action_content_new));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        menuItemAddNewEntryToDataTable.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }
    super.onPrepareOptionsMenu(menu);
}

From source file:org.catnut.fragment.OAuthFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    MenuItem refresh = menu.add(Menu.NONE, R.id.refresh, Menu.NONE, getString(R.string.refresh));
    refresh.setIcon(R.drawable.ic_action_retry);
    refresh.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
}

From source file:com.misczak.joinmybridge.EventFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    MenuItem item = menu.add("Search");
    item.setIcon(R.drawable.ic_search_white_24dp);
    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
    mSearchView = new MySearchView(getActivity());
    mSearchView.setOnQueryTextListener(this);
    mSearchView.setOnCloseListener(this);
    mSearchView.setIconifiedByDefault(true);
    item.setActionView(mSearchView);/*from w w w . j a va 2 s. com*/
}

From source file:org.strongswan.android.ui.SelectedApplicationsListFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    MenuItem item = menu.add(R.string.search);
    item.setIcon(android.R.drawable.ic_menu_search);
    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

    SearchView sv = new SearchView(getActivity());
    sv.setOnQueryTextListener(this);
    item.setActionView(sv);/*from w  ww  . j a v  a  2  s. c  o  m*/

    super.onCreateOptionsMenu(menu, inflater);
}

From source file:com.mifos.mifosxdroid.online.DocumentListFragment.java

@SuppressWarnings("deprecation")
@Override//from  ww w  .  j  av  a2 s  . c  o  m
public void onPrepareOptionsMenu(Menu menu) {
    menu.clear();
    MenuItem menuItemAddNewDocument = menu.add(Menu.NONE, MENU_ITEM_ADD_NEW_DOCUMENT, Menu.NONE,
            getString(R.string.add_new));
    menuItemAddNewDocument.setIcon(getResources().getDrawable(R.drawable.ic_action_content_new));

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
        menuItemAddNewDocument.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    super.onPrepareOptionsMenu(menu);
}

From source file:com.zbrown.droidsteal.activities.HijackActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    MenuItem menu0 = menu.add(0, 0, 0, getString(R.string.back));
    menu0.setIcon(R.drawable.ic_action_back);
    menu0.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);

    MenuItem menu1 = menu.add(0, 1, 0, getString(R.string.forward));
    menu1.setIcon(R.drawable.ic_action_forward);
    menu1.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);

    MenuItem menu2 = menu.add(0, 2, 0, getString(R.string.reload));
    menu2.setIcon(R.drawable.ic_action_refresh);
    menu2.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

    menu.add(0, 3, 0, getString(R.string.changeurl));
    menu.add(0, 4, 0, getString(R.string.close));
    return true;//from   w w w .  j  ava2s  . c o  m
}

From source file:com.yojiokisoft.globish1500.activity.MainActivity.java

private void setMenuIcon(MenuItem item) {
    if (mOmitMemorized) {
        item.setIcon(R.drawable.ic_action_filter_on);
    } else {//from w ww.j  ava  2 s  .  c om
        item.setIcon(R.drawable.ic_action_filter_off);
    }
}