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:rs.pedjaapps.kerneltuner.ui.BuildpropEditor.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    menu.add(0, 0, 0, getString(R.string.add)).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    menu.add(0, 1, 1, getString(R.string.backup)).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    menu.add(0, 2, 2, getString(R.string.restore)).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    return super.onCreateOptionsMenu(menu);
}

From source file:com.mifos.mifosxdroid.online.loancharge.LoanChargeFragment.java

@SuppressWarnings("deprecation")
@Override/*from  w  w  w . ja  va2 s  .  c  om*/
public void onPrepareOptionsMenu(Menu menu) {
    menu.clear();
    MenuItem menuItemAddNewLoanCharge = menu.add(Menu.NONE, MENU_ITEM_ADD_NEW_LOAN_CHARGES, Menu.NONE,
            getString(R.string.add_new));
    menuItemAddNewLoanCharge.setIcon(getResources().getDrawable(R.drawable.ic_add_white_24dp));

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

From source file:com.example.android.animationsdemo.GirdPagerSearchBarActivity.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(mInnerPager.getCurrentItem() > 0);
    mPrev.setEnabled(mInnerPager.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,
            (mInnerPager.getCurrentItem() == mPagerAdapter.getCount() - 1) ? R.string.action_finish
                    : R.string.action_next);
    mNext.setEnabled(!(mInnerPager.getCurrentItem() == mPagerAdapter.getCount() - 1));
    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
    return true;/*from   w w w .  j av  a2 s.co  m*/
}

From source file:com.activiti.android.app.fragments.HelpDialogFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    menu.clear();/*from www .  ja  va2 s.com*/

    refreshIcon = menu.add(Menu.NONE, R.id.menu_refresh, Menu.FIRST, R.string.refresh);
    refreshIcon.setIcon(R.drawable.ic_refresh_white);
    refreshIcon.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
}

From source file:org.alfresco.mobile.android.application.fragments.help.HelpDialogFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    if (!MenuFragmentHelper.canDisplayFragmentMenu(getActivity())) {
        return;//from w ww.ja v a  2s .  com
    }
    menu.clear();

    refreshIcon = menu.add(Menu.NONE, R.id.menu_refresh, Menu.FIRST, R.string.refresh);
    refreshIcon.setIcon(R.drawable.ic_refresh);
    refreshIcon.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
}

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;/*  w w w .j a  v  a  2s .  c om*/
}

From source file:org.webinos.android.app.wrt.ui.WidgetListActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    /* inflate the menu items for use in the action bar */
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.widget_list_activity_actions, menu);

    if (stores != null) {
        for (int i = 0; i < stores.length; i++) {
            Store store = stores[i];/*from  www. j  a v a 2s. co  m*/
            menu.add(Menu.NONE, STORES_MENUITEM_BASE + i, i + 1, store.name).setIcon(store.icon)
                    .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        }
    } else {
        Log.i(TAG, "Unable to add app store");
    }
    return super.onCreateOptionsMenu(menu);
}

From source file:com.mifos.mifosxdroid.online.clientcharge.ClientChargeFragment.java

@Override
public void onPrepareOptionsMenu(Menu menu) {
    menu.clear();/*  ww  w  .  j  a  v a2  s . c o  m*/
    MenuItem menuItemAddNewDocument = menu.add(Menu.NONE, MENU_ITEM_ADD_NEW_CHARGES, Menu.NONE,
            getString(R.string.add_new));
    menuItemAddNewDocument
            .setIcon(ResourcesCompat.getDrawable(getResources(), R.drawable.ic_add_white_24dp, null));

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

From source file:org.chromium.chrome.browser.preferences.Preferences.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    if (menu.size() == 1) {
        MenuItem item = menu.getItem(0);
        if (item.getIcon() != null)
            item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }/*from ww  w .j a  v  a2 s  . c om*/
    return super.onPrepareOptionsMenu(menu);
}

From source file:org.alfresco.mobile.android.application.fragments.user.UserProfileFragment.java

private void getMenu(Menu menu, int mode) {
    MenuItem mi = null;//w ww  . j  a v  a  2  s. c  om
    switch (mode) {
    case MODE_CALL:
        if (person.getTelephoneNumber() != null && !person.getTelephoneNumber().isEmpty()) {
            mi = menu.add(Menu.NONE, R.id.menu_user_phone, Menu.FIRST + 6, person.getTelephoneNumber());
            mi.setIcon(R.drawable.ic_call);
            mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        }

        if (person.getMobileNumber() != null && !person.getMobileNumber().isEmpty()) {
            mi = menu.add(Menu.NONE, R.id.menu_user_mobile, Menu.FIRST + 7, person.getMobileNumber());
            mi.setIcon(R.drawable.ic_call);
            mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        }

        if (person.getCompany() != null && person.getCompany().getTelephoneNumber() != null
                && !person.getCompany().getTelephoneNumber().isEmpty()) {
            mi = menu.add(Menu.NONE, R.id.menu_user_company_phone, Menu.FIRST + 5,
                    person.getCompany().getTelephoneNumber());
            mi.setIcon(R.drawable.ic_call);
            mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        }
        break;
    case MODE_SKYPE:
        mi = menu.add(Menu.NONE, R.id.menu_user_chat, Menu.FIRST, R.string.start_chat);
        mi.setIcon(R.drawable.ic_im);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

        mi = menu.add(Menu.NONE, R.id.menu_user_call, Menu.FIRST + 1, R.string.start_call);
        mi.setIcon(R.drawable.ic_call);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

        mi = menu.add(Menu.NONE, R.id.menu_user_videocall, Menu.FIRST + 2, R.string.start_video_call);
        mi.setIcon(R.drawable.ic_videos);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        break;
    case MODE_EMAIL:
        if (person.getEmail() != null && !person.getEmail().isEmpty()) {
            mi = menu.add(Menu.NONE, R.id.menu_user_email, Menu.FIRST + 3, person.getEmail());
            mi.setIcon(R.drawable.ic_send_mail);
            mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        }

        if (person.getCompany() != null && person.getCompany().getEmail() != null
                && !person.getCompany().getEmail().isEmpty()) {
            mi = menu.add(Menu.NONE, R.id.menu_user_company_email, Menu.FIRST + 4,
                    person.getCompany().getEmail());
            mi.setIcon(R.drawable.ic_send_mail);
            mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        }
        break;

    default:
        break;
    }

}