Example usage for android.view MenuItem SHOW_AS_ACTION_ALWAYS

List of usage examples for android.view MenuItem SHOW_AS_ACTION_ALWAYS

Introduction

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

Prototype

int SHOW_AS_ACTION_ALWAYS

To view the source code for android.view MenuItem SHOW_AS_ACTION_ALWAYS.

Click Source Link

Document

Always show this item as a button in an Action Bar.

Usage

From source file:org.chromium.chrome.browser.physicalweb.ListUrlsActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    int tintColor = ContextCompat.getColor(this, R.color.light_normal_color);

    Drawable tintedRefresh = ContextCompat.getDrawable(this, R.drawable.btn_toolbar_reload);
    tintedRefresh.setColorFilter(tintColor, PorterDuff.Mode.SRC_IN);
    menu.add(0, R.id.menu_id_refresh, 1, R.string.physical_web_refresh).setIcon(tintedRefresh)
            .setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS);

    menu.add(0, R.id.menu_id_close, 2, R.string.close).setIcon(R.drawable.btn_close)
            .setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS);

    return super.onCreateOptionsMenu(menu);
}

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

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    MenuItem submitItem = menu.add(Menu.NONE, R.id.submit_menu, Menu.NONE, R.string.submit_new_solution);
    submitItem.setIcon(R.drawable.ic_send_now_light);
    submitItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
}

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.commonsware.android.arXiv.arXiv.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    menu.add(Menu.NONE, SEARCH_ID, Menu.NONE, R.string.search).setIcon(R.drawable.ic_action_action_search)
            .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    populateMenu(menu);//from ww  w. j a  v  a2s.  c om
    this.menu = menu;
    return (super.onCreateOptionsMenu(menu));
}

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

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    MenuItem refreshMenuItem = menu.add(Menu.NONE, R.id.refresh_menu, 30, R.string.refresh);
    refreshMenuItem.setIcon(R.drawable.ic_refresh_light);
    refreshMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

    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:net.simonvt.cathode.ui.fragment.MovieFragment.java

@Override
public void createMenu(Toolbar toolbar) {
    super.createMenu(toolbar);
    Menu menu = toolbar.getMenu();

    if (loaded) {
        if (checkedIn) {
            menu.add(0, R.id.action_checkin_cancel, 1, R.string.action_checkin_cancel)
                    .setIcon(R.drawable.ic_action_cancel)
                    .setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
        } else if (!watching) {
            menu.add(0, R.id.action_checkin, 2, R.string.action_checkin).setIcon(R.drawable.ic_action_checkin)
                    .setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
        }// w w w  .  jav a  2s.co  m

        if (watched) {
            menu.add(0, R.id.action_unwatched, 3, R.string.action_unwatched);
        } else {
            menu.add(0, R.id.action_watched, 4, R.string.action_watched);
            if (inWatchlist) {
                menu.add(0, R.id.action_watchlist_remove, 7, R.string.action_watchlist_remove);
            } else {
                menu.add(0, R.id.action_watchlist_add, 8, R.string.action_watchlist_add);
            }
        }

        if (collected) {
            menu.add(0, R.id.action_collection_remove, 5, R.string.action_collection_remove);
        } else {
            menu.add(0, R.id.action_collection_add, 6, R.string.action_collection_add);
        }
    }
}

From source file:th.in.ffc.person.visit.VisitDiagActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.edit_activity, menu);
    String[] diagType = getResources().getStringArray(R.array.diag_DX);
    SubMenu sub = menu.addSubMenu(R.string.add);
    sub.add(0, 2, 0, diagType[2]);/*from   w w w. j  av  a  2s  . c o m*/
    sub.add(0, 4, 0, diagType[4]);
    sub.add(0, 5, 0, diagType[5]);
    sub.setIcon(R.drawable.ic_action_add);
    sub.getItem().setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS);
    return true;
}

From source file:org.alfresco.mobile.android.application.fragments.fileexplorer.FileActions.java

private void getMenu(Menu menu) {
    menu.clear();//from   w  w w . java2  s  .  c  om

    MenuItem mi;

    if (getFragment() instanceof ListingModeFragment) {
        switch (((ListingModeFragment) getFragment()).getMode()) {
        case FileExplorerFragment.MODE_LISTING:
            if (selectedFolder.isEmpty()) {
                mi = menu.add(Menu.NONE, R.id.menu_upload, Menu.FIRST + 30, R.string.upload);
                mi.setIcon(R.drawable.ic_upload);
                mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

                mi = menu.add(Menu.NONE, R.id.menu_action_share, Menu.FIRST + 100, R.string.share);
                mi.setIcon(R.drawable.ic_share);
                mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
            }

            mi = menu.add(Menu.NONE, R.id.menu_action_delete, Menu.FIRST + 1000, R.string.delete);
            mi.setIcon(R.drawable.ic_delete);
            mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
            break;

        case FileExplorerFragment.MODE_PICK:

            if (selectedFolder.isEmpty()) {
                mi = menu.add(Menu.NONE, R.id.menu_file_send, Menu.FIRST, R.string.action_upload);
                mi.setIcon(R.drawable.ic_upload);
                mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_WITH_TEXT | MenuItem.SHOW_AS_ACTION_ALWAYS);
            }

            break;

        default:
            break;
        }
        mi = menu.add(Menu.NONE, R.id.menu_select_all, Menu.FIRST + 200, R.string.select_all);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    }
}

From source file:com.qiscus.sdk.ui.QiscusBaseChatActivity.java

@Override
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
    menu.findItem(R.id.action_copy).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    menu.findItem(R.id.action_share).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    return true;//from  w  w  w  .  j a v a  2s .  c om
}

From source file:org.kosmakoff.pocketreckoner.ui.MainActivity.java

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

    switch (currentMenu) {
    case PEOPLE:/*ww w . ja  v a 2 s .c om*/
        MenuItem addPersonMenuItem = menu.add(Menu.NONE, R.id.menu_item_add_person, 10, R.string.add_person);
        addPersonMenuItem.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS);
        addPersonMenuItem.setIcon(R.drawable.ic_social_add_person);
        break;
    case CHECKS:
        MenuItem addCheckMenuItem = menu.add(Menu.NONE, R.id.menu_item_add_check, 10, R.string.add_check);
        addCheckMenuItem.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS);
        addCheckMenuItem.setIcon(R.drawable.ic_action_new_dark);
        break;
    default:
        break;
    }

    return true;
}