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:behsaman.storytellerandroid.TextviewerSlideActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.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) ? "Finish" : "Next");
    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
    return true;//from w w  w  .  jav a  2  s .  c o  m
}

From source file:de.stadtrallye.rallyesoft.fragments.ChatroomFragment.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_COLLAPSE_ACTION_VIEW);

    MenuItem pictureMenuItem = menu.add(Menu.NONE, R.id.picture_menu, 10, R.string.take_picture);

    pictureMenuItem.setIcon(R.drawable.ic_camera_light);
    pictureMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
}

From source file:edu.stanford.mobisocial.dungbeetle.ui.fragments.FeedActionsFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    MenuItem item;//from   w w  w.  j a va2  s .co m
    int placement = 0;
    Log.d(TAG, "creating menu " + mDualPane);
    if (mDualPane || MusubiBaseActivity.isDeveloperModeEnabled(getActivity())) {
        item = menu.add(0, MENU_VIEW, placement++, "View");
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        }
    }
    item = menu.add(0, MENU_SHARE, placement++, "Share");
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }

}

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

@Override
public void onPrepareOptionsMenu(Menu menu) {
    menu.clear();//from  www  .j  a v a2s  .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_action_content_new, null));

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

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

@Override
public void onPrepareOptionsMenu(Menu menu) {

    menu.clear();//from  www . jav a  2  s  .c  o  m

    MenuItem mItemSearch = menu.add(Menu.NONE, MENU_ITEM_SEARCH, Menu.NONE, getString(R.string.search));
    //        mItemSearch.setIcon(new IconDrawable(getActivity(), MaterialIcons.md_search)
    //                .colorRes(Color.WHITE)
    //                .actionBarSize());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        mItemSearch.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    }

    MenuItem mItemRefresh = menu.add(Menu.NONE, MENU_ITEM_REFRESH, Menu.NONE, getString(R.string.refresh));
    mItemRefresh.setIcon(
            new IconDrawable(getActivity(), MaterialIcons.md_refresh).colorRes(Color.WHITE).actionBarSize());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        mItemRefresh.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }

    MenuItem mItemSave = menu.add(Menu.NONE, MENU_ITEM_SAVE, Menu.NONE, getString(R.string.save));
    mItemSave.setIcon(
            new IconDrawable(getActivity(), MaterialIcons.md_save).colorRes(Color.WHITE).actionBarSize());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        mItemSave.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }

    super.onPrepareOptionsMenu(menu);

}

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

@SuppressWarnings("deprecation")
@Override//from  w w  w .j a va2  s.  c o m
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_action_content_new));

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

From source file:org.alfresco.mobile.android.application.fragments.workflow.process.ProcessesFragment.java

public static void getMenu(Context context, Menu menu) {
    MenuItem mi;/* w w w  .  ja va2 s. co  m*/

    mi = menu.add(Menu.NONE, R.id.menu_workflow_add, Menu.FIRST, R.string.workflow_start);
    mi.setIcon(android.R.drawable.ic_menu_add);
    mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

    MenuFragmentHelper.getMenu(context, menu);
}

From source file:com.willyan.viewpagerslideanimation.ScreenSlideActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.menu_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  w  w. j  a v  a2 s . c o m
}

From source file:com.mifos.mifosxdroid.online.collectionsheet.CollectionSheetFragment.java

@Override
public void onPrepareOptionsMenu(Menu menu) {

    menu.clear();/*w w w.  ja  v  a  2  s  .  c o m*/

    MenuItem mItemSearch = menu.add(Menu.NONE, MENU_ITEM_SEARCH, Menu.NONE, getString(R.string.search));
    //        mItemSearch.setIcon(new IconDrawable(getActivity(), MaterialIcons.md_search)
    //                .colorRes(Color.WHITE)
    //                .actionBarSize());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        mItemSearch.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    }

    MenuItem mItemRefresh = menu.add(Menu.NONE, MENU_ITEM_REFRESH, Menu.NONE, getString(R.string.refresh));
    mItemRefresh.setIcon(
            new IconDrawable(getActivity(), MaterialIcons.md_refresh).colorRes(R.color.white).actionBarSize());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        mItemRefresh.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }

    MenuItem mItemSave = menu.add(Menu.NONE, MENU_ITEM_SAVE, Menu.NONE, getString(R.string.save));
    mItemSave.setIcon(
            new IconDrawable(getActivity(), MaterialIcons.md_save).colorRes(R.color.white).actionBarSize());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        mItemSave.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }

    super.onPrepareOptionsMenu(menu);

}