Example usage for android.view MenuItem SHOW_AS_ACTION_IF_ROOM

List of usage examples for android.view MenuItem SHOW_AS_ACTION_IF_ROOM

Introduction

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

Prototype

int SHOW_AS_ACTION_IF_ROOM

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

Click Source Link

Document

Show this item as a button in an Action Bar if the system decides there is room for it.

Usage

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 w  w  .  ja  v  a2s. co  m
}

From source file:com.arantius.tivocommander.Utils.java

@SuppressLint("InlinedApi")
public final static void createFullOptionsMenu(Menu menu, Activity activity) {
    Utils.activateHomeButton(activity);/*from   w  w  w  .ja v a  2 s.com*/

    addToMenu(menu, activity, R.id.menu_item_remote, R.drawable.icon_remote, "Remote",
            MenuItem.SHOW_AS_ACTION_IF_ROOM);
    addToMenu(menu, activity, R.id.menu_item_my_shows, R.drawable.icon_tv32, "My Shows",
            MenuItem.SHOW_AS_ACTION_IF_ROOM);
    addToMenu(menu, activity, R.id.menu_item_search, R.drawable.icon_search, "Search",
            MenuItem.SHOW_AS_ACTION_IF_ROOM);
    addToMenu(menu, activity, R.id.menu_item_todo, R.drawable.icon_todo, "To Do List",
            MenuItem.SHOW_AS_ACTION_NEVER);
    addToMenu(menu, activity, R.id.menu_item_season_pass, R.drawable.icon_seasonpass, "Season Pass Manager",
            MenuItem.SHOW_AS_ACTION_NEVER);
    addToMenu(menu, activity, R.id.menu_item_devices, R.drawable.icon_devices, "Devices",
            MenuItem.SHOW_AS_ACTION_NEVER);
    addToMenu(menu, activity, R.id.menu_item_settings, R.drawable.icon_help, "Settings",
            MenuItem.SHOW_AS_ACTION_NEVER);
    addToMenu(menu, activity, R.id.menu_item_help, R.drawable.icon_help, "Help", MenuItem.SHOW_AS_ACTION_NEVER);
    addToMenu(menu, activity, R.id.menu_item_about, R.drawable.icon_info, "About",
            MenuItem.SHOW_AS_ACTION_NEVER);
}

From source file:ru.piter.fm.activities.RadioActivity.java

@Override
public boolean onCreateOptionsMenu(com.actionbarsherlock.view.Menu menu) {

    menu.add(0, 1, 1, R.string.ac_refresh).setIcon(R.drawable.ic_navigation_refresh)
            .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    menu.add(0, 2, 2, R.string.ac_settings).setIcon(R.drawable.ic_action_settings)
            .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    menu.add(0, 3, 3, R.string.ac_search).setIcon(R.drawable.ic_action_search)
            .setActionView(R.layout.action_search)
            .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
    menu.add(0, 4, 4, R.string.ac_exit).setIcon(R.drawable.ic_cancel)
            .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

    return super.onCreateOptionsMenu(menu);
}

From source file:com.example.ScreenSlideActivity.java

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

    menu.findItem(R.id.action_previous).setEnabled(mPager.getCurrentItem() > 0);

    // Add either a "next" or "finish" button to the action bar, depending on which page
    // is currently selected.
    MenuItem item = menu.add(Menu.NONE, R.id.action_previous, Menu.NONE,
            (mPager.getCurrentItem() == mPagerAdapter.getCount() - 1) ? "Finalizar" : "Siguiente");
    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
    return true;/*from   w w  w.  j  av  a2s .  c  o m*/
}

From source file:com.team.agita.langeo.ActivitySlideShow.java

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

    menu.findItem(R.id.action_previous).setEnabled(mPager.getCurrentItem() >= 0);

    // Add either a "next" or "finish" button to the action bar, depending on which page
    // is currently selected.
    MenuItem item = menu.add(Menu.NONE, R.id.action_next, Menu.NONE,
            (mPager.getCurrentItem() == mPagerAdapter.getCount() - 1) ? R.string.action_finish
                    : R.string.action_next);
    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
    return true;/*from   www . j av a 2  s  .c o  m*/
}

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

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.activity_screen_slide, menu);
    menu.findItem(R.id.action_previous).setEnabled(mPager.getCurrentItem() > 0);
    // Add either a "next" or "finish" button to the action bar, depending on which page
    // is currently selected.
    MenuItem item = menu.add(Menu.NONE, R.id.action_next, Menu.NONE,
            (mPager.getCurrentItem() == mPagerAdapter.getCount() - 1) ? R.string.action_finish
                    : R.string.action_next);
    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
    return true;// w ww . j  a va 2s.  com
}

From source file:org.codecyprus.android_client.ui.ActivityCategories.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    menu.add(R.string.REFRESH)/*from  www .  j  a  v a  2  s .  c  om*/
            .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);

    return true;
}

From source file:com.gsc.testing.espresso.espressotesting.ScreenSlideActivity.java

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

    menu.findItem(R.id.action_previous).setEnabled(mPager.getCurrentItem() > 0);

    // Add either a "next" or "finish" button to the action bar, depending on which page
    // is currently selected.
    MenuItem item = menu.add(Menu.NONE, R.id.action_next, Menu.NONE,
            (mPager.getCurrentItem() == mPagerAdapter.getCount() - 1) ? R.string.action_finish
                    : R.string.action_next);
    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
    return true;/* www  . j  a v  a  2  s.  c  om*/
}

From source file:com.keithcassidy.finishline.FinishLineMapFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {

    autoUpdateMenuItem = menu.add(R.string.menu_autozoom);
    autoUpdateMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    setAutoZoomIcon();/*from ww w .  java  2s .  c o  m*/
}

From source file:org.alfresco.mobile.android.application.fragments.node.details.NodeDetailsActionMode.java

protected void getMenu(FragmentActivity activity, Menu menu) {
    if (selectedItems.isEmpty() || selectedItems.size() > 1) {
        return;/* w w w.j  av  a2s  . c  o m*/
    }

    MenuItem mi;
    Node node = getCurrentItem();
    if (node == null) {
        return;
    }
    if (node instanceof NodeSyncPlaceHolder) {
        return;
    }

    boolean isRestrict = node.hasAspect(ContentModel.ASPECT_RESTRICTABLE);

    if (node.isDocument()) {
        if (((Document) node).getContentStreamLength() > 0 && !isRestrict && ConfigurableActionHelper
                .isVisible(getActivity(), getAccount(), ConfigurableActionHelper.ACTION_NODE_DOWNLOAD)) {
            mi = menu.add(Menu.NONE, R.id.menu_action_download, Menu.FIRST, R.string.download);
            mi.setIcon(R.drawable.ic_download_light);
            mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        }

        if (((Document) node).isLatestVersion() && ConfigurableActionHelper.isVisible(getActivity(),
                getAccount(), getSession(), node, ConfigurableActionHelper.ACTION_NODE_UPDATE)) {
            mi = menu.add(Menu.NONE, R.id.menu_action_update, Menu.FIRST + 130, R.string.update);
            mi.setIcon(R.drawable.ic_upload);
            mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        }

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

    if (ConfigurableActionHelper.isVisible(getActivity(), getAccount(), getSession(), node,
            ConfigurableActionHelper.ACTION_NODE_EDIT)) {
        mi = menu.add(Menu.NONE, R.id.menu_action_edit, Menu.FIRST + 50, R.string.edit);
        mi.setIcon(R.drawable.ic_properties);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }

    if (ConfigurableActionHelper.isVisible(getActivity(), getAccount(), getSession(), node,
            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);
    }
}