Example usage for android.view MenuItem setShowAsAction

List of usage examples for android.view MenuItem setShowAsAction

Introduction

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

Prototype

public void setShowAsAction(int actionEnum);

Source Link

Document

Sets how this item should display in the presence of an Action Bar.

Usage

From source file:net.lacolaco.smileessence.activity.EditExtractionActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuItem add = menu.add(Menu.NONE, R.id.menu_edit_list_add, Menu.NONE, "");
    add.setIcon(android.R.drawable.ic_menu_add);
    add.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    return true;// w  w w .  ja  va 2  s .  c o  m
}

From source file:org.peterbaldwin.vlcremote.app.PickServerActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    MenuItem scan = menu.add(0, MENU_SCAN, 0, R.string.scan);
    scan.setIcon(R.drawable.ic_menu_scan_network);
    scan.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
    return true;/* w  w w . ja  v  a  2s .  co m*/
}

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 ww.j a va2  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  ava2 s .co  m*/
}

From source file:com.jecelyin.android.file_explorer.FileExplorerAction.java

@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
    menu.add(0, R.id.select_all, 0, R.string.select_all).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    menu.add(0, R.id.cut, 0, R.string.cut).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    menu.add(0, R.id.copy, 0, R.string.copy).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);

    MenuItem pasteMenu = menu.add(0, R.id.paste, 0, R.string.paste);
    pasteMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    pasteMenu.setEnabled(fileClipboard.canPaste());

    renameMenu = menu.add(0, R.id.rename, 0, R.string.rename);
    renameMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);

    shareMenu = menu.add(0, R.id.share, 0, R.string.share);
    shareMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    shareActionProvider = new ShareActionProvider(context);
    shareActionProvider.setOnShareTargetSelectedListener(this);
    MenuItemCompat.setActionProvider(shareMenu, shareActionProvider);

    menu.add(0, R.id.delete, 0, R.string.delete).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    return true;//from ww w .jav a 2 s  .  c om
}

From source file:de.stadtrallye.rallyesoft.fragments.TasksPagerFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    MenuItem resize = menu.add(Menu.NONE, R.id.resize_menu, 40, R.string.resize);
    resize.setIcon(R.drawable.ic_center_light);
    resize.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
}

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;/*w  ww .  java2s.  c o  m*/
}

From source file:com.keithandthegirl.ui.activity.EpisodesActivity.java

@TargetApi(11)
@Override//from  w  ww  . ja  v a  2s .co  m
public boolean onCreateOptionsMenu(Menu menu) {
    Log.d(TAG, "onCreateOptionsMenu : enter");

    MenuItem settings = menu.add(Menu.NONE, SETTINGS_ID, Menu.NONE,
            getResources().getString(R.string.pref_settings_title));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        settings.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    }

    MenuItem about = menu.add(Menu.NONE, ABOUT_ID, Menu.NONE, getResources().getString(R.string.about_header));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        about.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    }

    Log.d(TAG, "onCreateOptionsMenu : exit");
    return super.onCreateOptionsMenu(menu);
}

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

public void getMenu(Menu menu, File f) {
    MenuItem mi;

    if (f.isFile()) {
        mi = menu.add(Menu.NONE, R.id.menu_action_share, Menu.FIRST, R.string.share);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);

        mi = menu.add(Menu.NONE, R.id.menu_upload, Menu.FIRST + 30, R.string.upload);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    }/*from   w ww.j ava 2  s .  c om*/

    if (f.canWrite() && downloadPath != null && f.getPath().startsWith(downloadPath)) {
        mi = menu.add(Menu.NONE, R.id.menu_action_delete, Menu.FIRST + 1000, R.string.delete);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    }

}

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