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:com.pacoapp.paco.ui.FindExperimentsActivity.java

@SuppressLint("NewApi")
@Override/* ww  w  .jav a2 s .  co  m*/
public boolean onCreateOptionsMenu(Menu menu) {
    int pos = 1;
    if (true || !mNavigationDrawerFragment.isDrawerOpen()) {
        getMenuInflater().inflate(R.menu.main, menu);
        //restoreActionBar();
        // TODO hide find experiments (this is that item)
        // TODO make refresh be an always action
        MenuItem findExperiments = menu.getItem(0);
        findExperiments.setVisible(false);
        MenuItem refreshExperiments = menu.getItem(1);
        refreshExperiments.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
        return true;
    }
    return super.onCreateOptionsMenu(menu);
}

From source file:com.pacoapp.paco.ui.FindMyExperimentsActivity.java

@SuppressLint("NewApi")
@Override//from   www .  jav a2  s . c om
public boolean onCreateOptionsMenu(Menu menu) {
    int pos = 1;
    if (true || !mNavigationDrawerFragment.isDrawerOpen()) {
        getMenuInflater().inflate(R.menu.main, menu);
        // restoreActionBar();
        // TODO hide find experiments (this is that item)
        // TODO make refresh be an always action
        MenuItem findExperiments = menu.getItem(0);
        findExperiments.setVisible(false);
        MenuItem refreshExperiments = menu.getItem(1);
        refreshExperiments.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
        return true;
    }
    return super.onCreateOptionsMenu(menu);
}

From source file:com.bluros.updater.UpdatesSettings.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    menu.add(0, MENU_REFRESH, 0, R.string.menu_refresh).setIcon(R.drawable.ic_menu_refresh)
            .setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);

    menu.add(0, MENU_DELETE_ALL, 0, R.string.menu_delete_all)
            .setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);

    menu.add(0, MENU_SYSTEM_INFO, 0, R.string.menu_system_info)
            .setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);

    return true;//w  w w.  j av a2 s .c  om
}

From source file:net.potterpcs.recipebook.RecipeViewer.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.viewermenu, menu);

    // Set up the action bar if we have one
    MenuItemCompat.setShowAsAction(menu.findItem(R.id.viewertimer),
            MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
    MenuItemCompat.setShowAsAction(menu.findItem(R.id.viewershare), MenuItem.SHOW_AS_ACTION_ALWAYS);
    MenuItemCompat.setShowAsAction(menu.findItem(R.id.viewerhelp), MenuItem.SHOW_AS_ACTION_IF_ROOM);

    // Set up Share menu item
    ShareCompat.configureMenuItem(menu.findItem(R.id.viewershare), shareIntent);

    return true;//from  w  w  w  . j  av  a 2s  . c om
}

From source file:com.mikepenz.actionitembadge.sample.ToolbarActivity.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);

    if (badgeCount == 0) {
        ActionItemBadge.hide(menu.findItem(R.id.item_samplebadge));
    } else {/*from  w ww .  ja  va 2 s  .c o m*/
        ActionItemBadge.update(this, menu.findItem(R.id.item_samplebadge), FontAwesome.Icon.faw_android, style,
                badgeCount);
    }
    if (badgeDrawableCount == 0) {
        ActionItemBadge.hide(menu.findItem(R.id.item_sampleBadge_drawable));
    } else {
        ActionItemBadge.update(this, menu.findItem(R.id.item_sampleBadge_drawable),
                ContextCompat.getDrawable(this, R.drawable.ic_notification), style,
                NumberUtils.formatNumber(badgeDrawableCount));
    }

    new ActionItemBadgeAdder().act(this).menu(menu).title(R.string.sample_2).itemDetails(0, SAMPLE2_ID, 1)
            .showAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS).add(bigStyle, 1);
    return true;
}

From source file:org.alfresco.mobile.android.application.fragments.actions.NodeActions.java

protected void getMenu(FragmentActivity activity, Menu menu) {
    MenuItem mi;/*  w  ww.  jav  a  2  s  . co  m*/
    SubMenu createMenu;

    if (selectedFolder.isEmpty()) {
        mi = menu.add(Menu.NONE, R.id.menu_action_download_all, Menu.FIRST, R.string.download);
        mi.setIcon(R.drawable.ic_download_light);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        removeActionIfNecessary(menu, mi.getItemId(), ConfigurableActionHelper.ACTION_NODE_DOWNLOAD);

        if (!(SessionUtils.getSession(activity) instanceof CloudSession)) {
            mi = menu.add(Menu.NONE, R.id.menu_workflow_review_attachments, Menu.FIRST + 500,
                    R.string.process_start_review);
            mi.setIcon(R.drawable.ic_start_review);
            mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
            removeActionIfNecessary(menu, mi.getItemId(), ConfigurableActionHelper.ACTION_NODE_REVIEW);
        }
    }

    // SYNC
    if (SyncContentManager.getInstance(getActivity()).hasActivateSync(getAccount())
            && !SyncContentManager.getInstance(getActivity()).isSynced(getAccount(), parentFolder)) {
        createMenu = menu.addSubMenu(Menu.NONE, R.id.menu_action_sync_group, Menu.FIRST, R.string.sync);
        createMenu.setIcon(R.drawable.ic_sync_light);
        createMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
        removeActionIfNecessary(menu, createMenu.getItem().getItemId(),
                ConfigurableActionHelper.ACTION_NODE_SYNC);

        createMenu.add(Menu.NONE, R.id.menu_action_sync_group_sync, Menu.FIRST + 1, R.string.sync);
        createMenu.add(Menu.NONE, R.id.menu_action_sync_group_unsync, Menu.FIRST + 2, R.string.unsync);
    }

    // FAVORITES
    createMenu = menu.addSubMenu(Menu.NONE, R.id.menu_action_favorite_group, Menu.FIRST + 135,
            R.string.favorite);
    createMenu.setIcon(R.drawable.ic_favorite_light);
    createMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    removeActionIfNecessary(menu, createMenu.getItem().getItemId(),
            ConfigurableActionHelper.ACTION_NODE_FAVORITE);

    createMenu.add(Menu.NONE, R.id.menu_action_favorite_group_favorite, Menu.FIRST + 1, R.string.favorite);
    createMenu.add(Menu.NONE, R.id.menu_action_favorite_group_unfavorite, Menu.FIRST + 2, R.string.unfavorite);

    // LIKE
    AlfrescoSession alfSession = SessionUtils.getSession(activity);
    if (alfSession != null && alfSession.getRepositoryInfo() != null
            && alfSession.getRepositoryInfo().getCapabilities() != null
            && alfSession.getRepositoryInfo().getCapabilities().doesSupportLikingNodes()) {
        createMenu = menu.addSubMenu(Menu.NONE, R.id.menu_action_like_group, Menu.FIRST + 150, R.string.like);
        createMenu.setIcon(R.drawable.ic_like);
        createMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        removeActionIfNecessary(menu, createMenu.getItem().getItemId(),
                ConfigurableActionHelper.ACTION_NODE_LIKE);

        createMenu.add(Menu.NONE, R.id.menu_action_like_group_like, Menu.FIRST + 1, R.string.like);
        createMenu.add(Menu.NONE, R.id.menu_action_like_group_unlike, Menu.FIRST + 2, R.string.unlike);
    }

    if (parentFolder != null && ConfigurableActionHelper.isVisible(getActivity(), getAccount(), getSession(),
            parentFolder, ConfigurableActionHelper.ACTION_NODE_DELETE)) {
        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);
        removeActionIfNecessary(menu, mi.getItemId(), ConfigurableActionHelper.ACTION_NODE_DELETE);
    }
}

From source file:com.keithandthegirl.ui.activity.GuestsDashboardFragment.java

@Override
@TargetApi(11)/* w  ww  . ja v  a  2 s .c om*/
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    Log.v(TAG, "onCreateOptionsMenu : enter");
    super.onCreateOptionsMenu(menu, inflater);

    MenuItem refresh = menu.add(Menu.NONE, REFRESH_ID, Menu.NONE,
            getResources().getString(R.string.menu_refresh));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        refresh.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    }

    MenuItem mostRecent = menu.add(Menu.NONE, MOST_RECENT_ID, Menu.NONE,
            getResources().getString(R.string.menu_most_recent));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        mostRecent.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    }

    MenuItem topCount = menu.add(Menu.NONE, TOP_COUNT_ID, Menu.NONE,
            getResources().getString(R.string.menu_top_count));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        topCount.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    }

    MenuItem name = menu.add(Menu.NONE, NAME_ID, Menu.NONE, getResources().getString(R.string.menu_name));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        name.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    }

    Log.v(TAG, "onCreateOptionsMenu : exit");
}

From source file:com.wheelly.fragments.LocationsListFragment.java

@SuppressWarnings("deprecation")
@Override/*from  w ww.jav  a 2  s . c  om*/
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    MenuCompat.setShowAsAction(
            menu.add(0, MENU_ADD, 0, R.string.item_add).setIcon(android.R.drawable.ic_menu_add),
            MenuItem.SHOW_AS_ACTION_ALWAYS);
}

From source file:com.example.google.location.LocationActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuItem menuItem = menu.add(R.string.clear_map);
    menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        @Override//  www  . ja va  2  s . c  o  m
        public boolean onMenuItemClick(MenuItem item) {
            clearMap();
            return true;
        }
    });
    return true;
}

From source file:nl.sogeti.android.gpstracker.viewer.TrackList.java

/*******************************************************************/

@Override//from w  w w  . j  a va2s .  c  o  m
public boolean onCreateOptionsMenu(Menu menu) {
    boolean result = super.onCreateOptionsMenu(menu);
    MenuItem item;
    item = menu.add(ContextMenu.NONE, MENU_SEARCH, ContextMenu.NONE, android.R.string.search_go)
            .setIcon(R.drawable.ic_search_24dp).setAlphabeticShortcut(SearchManager.MENU_KEY);
    MenuItemCompat.setShowAsAction(item, MenuItem.SHOW_AS_ACTION_ALWAYS);
    item = menu.add(ContextMenu.NONE, MENU_PICKER, ContextMenu.NONE, R.string.menu_picker)
            .setIcon(R.drawable.ic_import_24dp);
    MenuItemCompat.setShowAsAction(item, MenuItem.SHOW_AS_ACTION_ALWAYS);
    item = menu.add(ContextMenu.NONE, MENU_VACUUM, ContextMenu.NONE, R.string.menu_vacuum)
            .setIcon(android.R.drawable.ic_menu_crop);
    MenuItemCompat.setShowAsAction(item, MenuItem.SHOW_AS_ACTION_NEVER);
    return result;
}