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:com.mifos.mifosxdroid.online.DocumentListFragment.java

@SuppressWarnings("deprecation")
@Override//  w  ww . ja v a  2 s.  c o m
public void onPrepareOptionsMenu(Menu menu) {
    menu.clear();
    MenuItem menuItemAddNewDocument = menu.add(Menu.NONE, MENU_ITEM_ADD_NEW_DOCUMENT, Menu.NONE,
            getString(R.string.add_new));
    menuItemAddNewDocument.setIcon(getResources().getDrawable(R.drawable.ic_action_content_new));

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

From source file:us.opcam.camera.activity.URLImagePagerActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    if (bThisPicMine) // ? ?  ? 
    {//from  w ww  .j a  v a2s.  c o  m
        menu.add("Delete").setIcon(R.drawable.icon_delete)
                .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
    }

    return super.onCreateOptionsMenu(menu);
}

From source file:cz.msebera.unbound.dns.fragments.UnboundConfiguration.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    menu.add(Menu.NONE, MENU_SAVE, Menu.NONE, R.string.menu_save_changes)
            .setIcon(android.R.drawable.ic_menu_save).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    super.onCreateOptionsMenu(menu, inflater);
}

From source file:th.in.ffc.person.visit.VisitEpiActivity.java

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

    MenuItem item = menu.add(0, R.string.appoint, 2, R.string.appoint);
    item.setIcon(R.drawable.ic_action_epi_appoint);
    item.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    return true;// w ww. j  a v a2 s .  c o  m
}

From source file:android.example.com.animationdemos.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;/*from ww w. j  a v  a 2 s .  com*/
}

From source file:com.zyq.uitoucheventtest.animator.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.mipmap.ic_action_photo : R.mipmap.ic_action_info);
    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    return true;//  w ww  .j  a va 2s  .co m
}

From source file:cn.androidy.materialdesignsample.animations.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;//from  ww  w .j  a v  a2  s  .  c  o m
}

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

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

    MenuItem clearListMenuItem = menu.add(R.string.menu_clear_crossing_times);
    clearListMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    clearListMenuItem.setIcon(android.R.drawable.ic_menu_delete);

    clearListMenuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {

        @Override//  w w  w  .  jav  a 2 s .co m
        public boolean onMenuItemClick(MenuItem item) {
            try {
                deleteCrossings();
            } catch (Exception e) {
                Log.e(TAG, "onMenuItemClick " + e);
            }
            return true;
        }
    });

    MenuItem shareMenuItem = menu.add(R.string.menu_share);
    shareMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    shareMenuItem.setIcon(android.R.drawable.ic_menu_share);

    shareMenuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            try {
                sendCurrentCrossing();
            } catch (Exception e) {
                Log.e(TAG, "onMenuItemClick " + e);
            }
            return true;
        }
    });

    super.onCreateOptionsMenu(menu, inflater);
}

From source file:com.pepperonas.truthordare.fragments.FragmentMultiplayer.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:cz.msebera.unbound.dns.fragments.UnboundCheckConf.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    menu.add(Menu.NONE, MENU_RUN, Menu.NONE, R.string.checkconf_menu_run_check)
            .setIcon(android.R.drawable.ic_media_play).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    super.onCreateOptionsMenu(menu, inflater);
}