Example usage for android.view MenuItem SHOW_AS_ACTION_WITH_TEXT

List of usage examples for android.view MenuItem SHOW_AS_ACTION_WITH_TEXT

Introduction

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

Prototype

int SHOW_AS_ACTION_WITH_TEXT

To view the source code for android.view MenuItem SHOW_AS_ACTION_WITH_TEXT.

Click Source Link

Document

When this item is in the action bar, always show it with a text label even if it also has an icon specified.

Usage

From source file:com.evvsoft.treeview.demo.DemoActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    SubMenu sub = menu.addSubMenu("Theme");
    sub.add(0, R.style.Theme_TreeView_Light, 0, "Light");
    sub.add(0, R.style.Theme_TreeView_Dark, 0, "Dark");
    sub.add(0, R.drawable.expander_custom_group_holo_light, 0, "Custom group indicator");
    sub.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
    return true;//from w  ww. j a  v  a 2s. c  o  m
}

From source file:finalproject.ece558.edu.pdx.ece.brailleblackjack.LearnBrailleActivity.java

/**
 * Create the action menu to provide buttons to navigate the Pager
 * @param menu Menu object/*from  w ww  .j av a 2  s  .  c o m*/
 * @return Boolean true
 */
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.menu_main, menu);

    // Add/enable previous button depending on which page is active
    // is currently selected.
    MenuItem prev_item = menu.add(Menu.NONE, R.id.action_previous, Menu.NONE, R.string.action_previous);

    prev_item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);

    menu.findItem(R.id.action_previous).setEnabled(mPager.getCurrentItem() > 0);

    // Add either a "next" or "finished" button to the action bar, depending on which page
    // is currently active.
    MenuItem next_item = menu.add(Menu.NONE, R.id.action_next, Menu.NONE,
            (mPager.getCurrentItem() == mPagerAdapter.getCount() - 1) ? R.string.action_finish
                    : R.string.action_next);
    next_item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);

    menu.findItem(R.id.action_next).setEnabled(!(mPager.getCurrentItem() == 3));

    menu.findItem(R.id.action_next).setEnabled(mPager.getCurrentItem() < 3);
    return true;
}

From source file:com.examples.abelanav2.ui.PicturesFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    MenuItem refreshMenu = menu.add(R.string.action_refresh);
    refreshMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
    refreshMenu.setOnMenuItemClickListener(this);
    super.onCreateOptionsMenu(menu, inflater);
}

From source file:org.epstudios.epcoding.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;//  ww  w.  j  a  va  2  s .  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;/* ww w .j  a  v a  2s  . c  o  m*/
}

From source file:com.example.shyam.popi.LearnEmotions.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    setVolumeControlStream(AudioManager.STREAM_MUSIC);
    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_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
    return true;//from  w w  w  . ja va2 s  .c o  m
}

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;//from   ww  w .  j  a  v a  2 s.  com
}

From source file:com.thesis.asa.mainui.MainSlideActivity.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(pager.getCurrentItem() > 0);

    MenuItem item = menu.add(Menu.NONE, R.id.action_next, Menu.NONE,
            (pager.getCurrentItem() == pagerAdapter.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  .ja v a2  s.com
}

From source file:com.notifry.android.ChooseAccount.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    boolean result = super.onCreateOptionsMenu(menu);
    menu.add(0, REFRESH_IDS, 0, R.string.refresh_ids).setIcon(android.R.drawable.ic_menu_rotate)
            .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
    return result;
}

From source file:net.potterpcs.recipebook.RecipeBookActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.mainmenu, menu);

    // Set up the action bar, if we have one. (Pre-Honeycomb devices don't) 
    MenuItemCompat.setShowAsAction(menu.findItem(R.id.menunew),
            MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
    MenuItemCompat.setShowAsAction(menu.findItem(R.id.menushowall),
            MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
    MenuItemCompat.setShowAsAction(menu.findItem(R.id.menuhelp), MenuItem.SHOW_AS_ACTION_IF_ROOM);
    MenuItemCompat.setShowAsAction(menu.findItem(R.id.menuexport), MenuItem.SHOW_AS_ACTION_NEVER);
    MenuItemCompat.setShowAsAction(menu.findItem(R.id.menuprefs), MenuItem.SHOW_AS_ACTION_IF_ROOM);

    hideShowAllItem(menu);/*from   ww w .j a  v a  2  s.co m*/
    setSortOptions(menu);
    return true;
}