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.giantturtle.badenumbersquiz.PrepareYourSelfActivity.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)//ako je predposlednja stranica onda  da prikae finish, a ako nije predposlednja
                    ? 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  ww  .  jav  a  2s  .  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  ww .  j av a2s  .c o m
}

From source file:net.simonvt.cathode.ui.fragment.MovieFragment.java

@Override
public void createMenu(Toolbar toolbar) {
    super.createMenu(toolbar);
    Menu menu = toolbar.getMenu();

    if (loaded) {
        if (checkedIn) {
            menu.add(0, R.id.action_checkin_cancel, 1, R.string.action_checkin_cancel)
                    .setIcon(R.drawable.ic_action_cancel)
                    .setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
        } else if (!watching) {
            menu.add(0, R.id.action_checkin, 2, R.string.action_checkin).setIcon(R.drawable.ic_action_checkin)
                    .setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
        }/*  www .  j  ava  2  s  .  co  m*/

        if (watched) {
            menu.add(0, R.id.action_unwatched, 3, R.string.action_unwatched);
        } else {
            menu.add(0, R.id.action_watched, 4, R.string.action_watched);
            if (inWatchlist) {
                menu.add(0, R.id.action_watchlist_remove, 7, R.string.action_watchlist_remove);
            } else {
                menu.add(0, R.id.action_watchlist_add, 8, R.string.action_watchlist_add);
            }
        }

        if (collected) {
            menu.add(0, R.id.action_collection_remove, 5, R.string.action_collection_remove);
        } else {
            menu.add(0, R.id.action_collection_add, 6, R.string.action_collection_add);
        }
    }
}

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

private void getMenu(Menu menu) {
    menu.clear();/*from  w  w  w. ja  v a  2 s  .co m*/

    MenuItem mi;

    if (getFragment() instanceof ListingModeFragment) {
        switch (((ListingModeFragment) getFragment()).getMode()) {
        case FileExplorerFragment.MODE_LISTING:
            if (selectedFolder.isEmpty()) {
                mi = menu.add(Menu.NONE, R.id.menu_upload, Menu.FIRST + 30, R.string.upload);
                mi.setIcon(R.drawable.ic_upload);
                mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

                mi = menu.add(Menu.NONE, R.id.menu_action_share, Menu.FIRST + 100, R.string.share);
                mi.setIcon(R.drawable.ic_share);
                mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
            }

            mi = menu.add(Menu.NONE, R.id.menu_action_delete, Menu.FIRST + 1000, R.string.delete);
            mi.setIcon(R.drawable.ic_delete);
            mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
            break;

        case FileExplorerFragment.MODE_PICK:

            if (selectedFolder.isEmpty()) {
                mi = menu.add(Menu.NONE, R.id.menu_file_send, Menu.FIRST, R.string.action_upload);
                mi.setIcon(R.drawable.ic_upload);
                mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_WITH_TEXT | MenuItem.SHOW_AS_ACTION_ALWAYS);
            }

            break;

        default:
            break;
        }
        mi = menu.add(Menu.NONE, R.id.menu_select_all, Menu.FIRST + 200, R.string.select_all);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    }
}

From source file:com.android.settings.profiles.ProfilesSettings.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    menu.add(0, MENU_RESET, 0, R.string.profile_reset_title).setIcon(R.drawable.ic_settings_backup) // use the backup icon
            .setAlphabeticShortcut('r').setEnabled(mEnabled)
            .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);

    menu.add(0, MENU_ADD, 0, R.string.profiles_add).setIcon(R.drawable.ic_menu_add).setAlphabeticShortcut('a')
            .setEnabled(mEnabled)/*from  ww  w . ja v  a2s.c om*/
            .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
}

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

From source file:com.android.mms.ui.SelectRecipientsList.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Load the required preference values
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    mMobileOnly = sharedPreferences.getBoolean(PREF_MOBILE_NUMBERS_ONLY, true);

    menu.add(0, MENU_DONE, 0, R.string.menu_done).setIcon(R.drawable.ic_menu_done)
            .setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT)
            .setVisible(false);// www.  j  av  a2  s .co  m

    menu.add(0, MENU_MOBILE, 0, R.string.menu_mobile).setCheckable(true).setChecked(mMobileOnly)
            .setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_NEVER | MenuItem.SHOW_AS_ACTION_WITH_TEXT);

    boolean useAltNameOrdering = mContactsPreferences
            .getSortOrder() == ContactsPreferences.SORT_ORDER_ALTERNATIVE;
    int nameOrderItemTitleRes = useAltNameOrdering ? R.string.menu_order_by_given_name
            : R.string.menu_order_by_last_name;

    menu.add(0, MENU_NAME_ORDER, 0, nameOrderItemTitleRes)
            .setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_NEVER | MenuItem.SHOW_AS_ACTION_WITH_TEXT);

    return super.onCreateOptionsMenu(menu);
}

From source file:com.example.android.animationsdemo.GirdPagerSearchBarActivity.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(mInnerPager.getCurrentItem() > 0);
    mPrev.setEnabled(mInnerPager.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,
            (mInnerPager.getCurrentItem() == mPagerAdapter.getCount() - 1) ? R.string.action_finish
                    : R.string.action_next);
    mNext.setEnabled(!(mInnerPager.getCurrentItem() == mPagerAdapter.getCount() - 1));
    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
    return true;//  w ww.j  a va  2s .c o  m
}

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

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

    // Set up the action bar if we have one
    MenuItemCompat.setShowAsAction(menu.findItem(R.id.viewertimer),
            MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
    MenuItemCompat.setShowAsAction(menu.findItem(R.id.viewershare), MenuItem.SHOW_AS_ACTION_ALWAYS);
    MenuItemCompat.setShowAsAction(menu.findItem(R.id.viewerhelp), MenuItem.SHOW_AS_ACTION_IF_ROOM);

    // Set up Share menu item
    ShareCompat.configureMenuItem(menu.findItem(R.id.viewershare), shareIntent);

    return true;/*  www.j a  v  a2  s.c  om*/
}

From source file:com.bluros.updater.UpdatesSettings.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    menu.add(0, MENU_REFRESH, 0, R.string.menu_refresh).setIcon(R.drawable.ic_menu_refresh)
            .setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);

    menu.add(0, MENU_DELETE_ALL, 0, R.string.menu_delete_all)
            .setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);

    menu.add(0, MENU_SYSTEM_INFO, 0, R.string.menu_system_info)
            .setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);

    return true;/*from  w  w w .ja  v  a2 s.co m*/
}