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:Main.java

public static void setShowMenuAsAction(MenuItem menuItem) {
    setShowMenuAsAction(menuItem, MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
}

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

public static MenuItem getMenu(Context context, Menu menu) {
    if (menu == null || context == null) {
        return null;
    }/*from   www .j a  v  a2  s .  c o m*/
    if (AccessibilityUtils.isEnabled(context)) {
        MenuItem mi = menu.add(Menu.NONE, R.id.menu_refresh, Menu.FIRST + 40, R.string.refresh);
        mi.setIcon(R.drawable.ic_refresh);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        return mi;
    } else {
        return null;
    }
}

From source file:com.example.android.actionbarcompat.basic.MainActivity.java

/**
 * Use this method to instantiate your menu, and add your items to it. You
 * should return true if you have added items to it and want the menu to be displayed.
 */// w  ww.  j a v  a2 s.  c o  m
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate our menu from the resources by using the menu inflater.
    getMenuInflater().inflate(R.menu.main, menu);

    // It is also possible add items here. Use a generated id from
    // resources (ids.xml) to ensure that all menu ids are distinct.
    MenuItem locationItem = menu.add(0, R.id.menu_location, 0, R.string.menu_location);
    locationItem.setIcon(R.drawable.ic_action_location);

    // Need to use MenuItemCompat methods to call any action item related methods
    MenuItemCompat.setShowAsAction(locationItem, MenuItem.SHOW_AS_ACTION_IF_ROOM);

    return true;
}

From source file:com.pepperonas.truthordare.fragments.FragmentTwoPlayer.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    menu.add(0, 0, 0, "Start").setIcon(R.drawable.ic_marked_circle_white_24dp)
            .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

    menu.getItem(0).setOnMenuItemClickListener(this);
}

From source file:com.darsihmad.slideScreen.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);

    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  av  a 2s. c  o  m
}

From source file:net.sakuramilk.kbcupdater.MainFragmentActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    menu.add("Update list");
    MenuItem actionItem = menu.add("Update list");
    actionItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    actionItem.setIcon(android.R.drawable.ic_menu_manage);

    return true;//from  w  ww.  j ava 2s .co m
}

From source file:com.grarak.kerneladiutor.activities.EditorActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    Drawable drawable = ContextCompat.getDrawable(this, R.drawable.ic_save);
    DrawableCompat.setTint(drawable, Color.WHITE);
    menu.add(0, Menu.FIRST, Menu.FIRST, getString(R.string.save)).setIcon(drawable)
            .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    return super.onCreateOptionsMenu(menu);
}

From source file:com.mifos.mifosxdroid.online.DataTableDataFragment.java

@SuppressWarnings("deprecation")
@Override//w  w w  . ja  va 2  s  .  c om
public void onPrepareOptionsMenu(Menu menu) {
    menu.clear();
    MenuItem menuItemAddNewEntryToDataTable = menu.add(Menu.NONE, MEUN_ITEM_ADD_NEW_ENTRY, Menu.NONE,
            getString(R.string.add_new));
    menuItemAddNewEntryToDataTable.setIcon(getResources().getDrawable(R.drawable.ic_action_content_new));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        menuItemAddNewEntryToDataTable.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }
    super.onPrepareOptionsMenu(menu);
}

From source file:com.example.cardflipanimation.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;/*  ww w  .  j  a  v a  2 s . c o  m*/
}

From source file:com.example.ward.view.CursorFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    // Place an action bar item for searching.
    MenuItem item = menu.add("Search");
    item.setIcon(android.R.drawable.ic_menu_search);
    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
    SearchView sv = new SearchView(getActivity());
    sv.setOnQueryTextListener(this);
    item.setActionView(sv);//w  w w . j  a v a2s  .c  om
}