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:fr.bmartel.android.iotf.app.ConnectActivity.java

@Override
public void displayDisconnect(MenuItem menuItem) {
    menuItem.setIcon(R.drawable.disconnect3);
}

From source file:org.peterbaldwin.vlcremote.app.PickServerActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    MenuItem scan = menu.add(0, MENU_SCAN, 0, R.string.scan);
    scan.setIcon(R.drawable.ic_menu_scan_network);
    scan.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
    return true;/*from   w  w  w  .j ava  2 s .c o m*/
}

From source file:net.lacolaco.smileessence.activity.EditExtractionActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuItem add = menu.add(Menu.NONE, R.id.menu_edit_list_add, Menu.NONE, "");
    add.setIcon(android.R.drawable.ic_menu_add);
    add.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    return true;/*from  w  ww . j a va2s . co m*/
}

From source file:de.tap.easy_xkcd.fragments.overview.OverviewBaseFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.menu_overview_fragment, menu);
    menu.findItem(R.id.action_boomark).setVisible(prefHelper.getBookmark() != 0)
            .setTitle(R.string.open_bookmark);
    menu.findItem(R.id.action_hide_read).setChecked(prefHelper.hideRead());
    menu.findItem(R.id.action_search).setVisible(false);
    menu.findItem(R.id.action_boomark).setVisible(bookmark != 0);

    MenuItem fav = menu.findItem(R.id.action_favorite);
    if (!prefHelper.overviewFav()) {
        fav.setIcon(R.drawable.ic_favorite_outline);
        fav.setTitle(R.string.nv_favorites);
    } else {//from  www.  ja v a2  s.  co m
        fav.setIcon(R.drawable.ic_action_favorite);
        fav.setTitle(R.string.action_overview);
    }

    super.onCreateOptionsMenu(menu, inflater);
}

From source file:org.chromium.chrome.browser.preferences.website.UsbChooserPreferences.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    menu.clear();//  ww w .ja  v  a 2  s.c  o  m
    inflater.inflate(R.menu.website_preferences_menu, menu);

    MenuItem searchItem = menu.findItem(R.id.search);
    mSearchView = (SearchView) MenuItemCompat.getActionView(searchItem);
    mSearchView.setImeOptions(EditorInfo.IME_FLAG_NO_FULLSCREEN);
    SearchView.OnQueryTextListener queryTextListener = new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            return true;
        }

        @Override
        public boolean onQueryTextChange(String query) {
            // Make search case-insensitive.
            query = query.toLowerCase();

            if (query.equals(mSearch))
                return true;

            mSearch = query;
            getInfo();
            return true;
        }
    };
    mSearchView.setOnQueryTextListener(queryTextListener);

    MenuItem help = menu.add(Menu.NONE, R.id.menu_id_targeted_help, Menu.NONE, R.string.menu_help);
    help.setIcon(R.drawable.ic_help_and_feedback);
}

From source file:yuejia.liu.musseta.components.settings.SettingsActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuItem os = menu.add(Menu.NONE, android.R.id.button1, Menu.NONE, "Open Source");
    os.setIcon(R.drawable.ic_code_white_24dp);
    MenuItemCompat.setShowAsAction(os, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
    return true;//from  w  ww .j ava 2 s .  com
}

From source file:de.stadtrallye.rallyesoft.fragments.TasksPagerFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    MenuItem resize = menu.add(Menu.NONE, R.id.resize_menu, 40, R.string.resize);
    resize.setIcon(R.drawable.ic_center_light);
    resize.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
}

From source file:com.hbm.devices.scan.ui.android.ScanActivity.java

private void handlePause(@NonNull MenuItem item) {
    if (adapter.isPaused()) {
        item.setIcon(R.drawable.ic_action_pause);
        adapter.resumeDeviceUpdates();//from  w w  w.  j ava2s.c o m
    } else {
        item.setIcon(R.drawable.ic_action_play);
        adapter.pauseDeviceUpdates();
    }
}

From source file:android.example.com.animationdemos.CardFlipActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    // Add either a "photo" or "finish" button to the action bar, depending on which page
    // is currently selected.
    MenuItem item = menu.add(Menu.NONE, R.id.action_flip, Menu.NONE,
            mShowingBack ? R.string.action_photo : R.string.action_info);
    item.setIcon(mShowingBack ? R.drawable.ic_action_photo : R.drawable.ic_action_info);
    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    return true;//w  ww.  j  av a 2s. c om
}

From source file:com.dm.material.dashboard.candybar.activities.CandyBarMuzeiActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_muzei, menu);
    MenuItem save = menu.findItem(R.id.menu_save);
    int color = ColorHelper.getAttributeColor(this, R.attr.toolbar_icon);
    save.setIcon(DrawableHelper.getTintedDrawable(this, R.drawable.ic_toolbar_save, color));
    return super.onCreateOptionsMenu(menu);
}