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:quarkstar.android.javainterviewquestions.MainActivity.java

private void setupSearchView(MenuItem searchItem) {

    if (isAlwaysExpanded()) {
        mSearchView.setIconifiedByDefault(false);
    } else {/*from  w w w. j a  va  2s .  c  om*/
        searchItem.setShowAsActionFlags(
                MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
    }

    /*        SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
            if (searchManager != null) {
    List<SearchableInfo> searchables = searchManager.getSearchablesInGlobalSearch();
             
    SearchableInfo info = searchManager.getSearchableInfo(getComponentName());
    for (SearchableInfo inf : searchables) {
        if (inf.getSuggestAuthority() != null
                && inf.getSuggestAuthority().startsWith("applications")) {
            info = inf;
        }
    }
    mSearchView.setSearchableInfo(info);
            }
    */
    mSearchView.setOnQueryTextListener(this);
}

From source file:org.codecyprus.android_client.ui.ActivityStartQuiz.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    menu.add(R.string.ENTER_CODE)/*w  w  w. jav  a2 s .c  om*/
            .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);

    return true;
}

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;//from ww w.ja  v a2s . c om
}

From source file:at.jclehner.appopsxposed.SettingsActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    if (Util.isSystemApp(this)) {
        menu.add(R.string.uninstall).setIcon(android.R.drawable.ic_menu_delete)
                .setOnMenuItemClickListener(new OnMenuItemClickListener() {

                    @Override/*from  w w w.j  a v a2 s  .c  o  m*/
                    public boolean onMenuItemClick(MenuItem item) {
                        final AlertDialog.Builder ab = new AlertDialog.Builder(SettingsActivity.this);
                        ab.setMessage(getString(R.string.uninstall) + "? " + getString(R.string.will_reboot));
                        ab.setNegativeButton(android.R.string.cancel, null);
                        ab.setPositiveButton(android.R.string.ok, new OnClickListener() {

                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                if (!SU.available()) {
                                    Toast.makeText(SettingsActivity.this, R.string.toast_needs_root,
                                            Toast.LENGTH_SHORT).show();
                                } else {
                                    final String[] commands = { "mount -o remount,rw /system",
                                            "rm " + LauncherActivity.SYSTEM_APK, "mount -o remount,ro /system",
                                            "sync", "reboot", };

                                    Toast.makeText(SettingsActivity.this, R.string.will_reboot,
                                            Toast.LENGTH_LONG).show();
                                    Util.runAsSu(commands);
                                }
                            }
                        });

                        ab.show();

                        return true;
                    }
                }).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }

    return true;
}

From source file:com.wheelly.fragments.LocationsMapFragment.java

@SuppressWarnings("deprecation")
@Override//from   w w w  .  ja  va 2  s.  c o  m
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    MenuCompat.setShowAsAction(
            menu.add(Menu.NONE, 1, Menu.NONE, R.string.item_add).setIcon(android.R.drawable.ic_menu_add),
            MenuItem.SHOW_AS_ACTION_IF_ROOM);
}

From source file:com.wenhui.syncedListView.demo.demo.SyncListViewContainerFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    String title = (mLayout.isAnimating()) ? "Stop anim" : "Start anim";
    mAnimMenu = menu.add(Menu.NONE, R.id.animation, 0, title);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        mAnimMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }//  w  ww.j  a  v  a 2s .  co  m
    super.onCreateOptionsMenu(menu, inflater);
}

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:com.facebook.react.views.toolbar.ReactToolbarManager.java

@Nullable
@Override// w  w  w.j  av a 2 s .c  om
public Map<String, Object> getExportedViewConstants() {
    return MapBuilder.<String, Object>of("ShowAsAction", MapBuilder.of("never", MenuItem.SHOW_AS_ACTION_NEVER,
            "always", MenuItem.SHOW_AS_ACTION_ALWAYS, "ifRoom", MenuItem.SHOW_AS_ACTION_IF_ROOM));
}

From source file:com.zbrown.droidsteal.activities.HijackActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    MenuItem menu0 = menu.add(0, 0, 0, getString(R.string.back));
    menu0.setIcon(R.drawable.ic_action_back);
    menu0.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);

    MenuItem menu1 = menu.add(0, 1, 0, getString(R.string.forward));
    menu1.setIcon(R.drawable.ic_action_forward);
    menu1.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);

    MenuItem menu2 = menu.add(0, 2, 0, getString(R.string.reload));
    menu2.setIcon(R.drawable.ic_action_refresh);
    menu2.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

    menu.add(0, 3, 0, getString(R.string.changeurl));
    menu.add(0, 4, 0, getString(R.string.close));
    return true;//w  ww  . j  ava 2  s .c o m
}

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 www. j  a v  a2s. c o m*/
    setSortOptions(menu);
    return true;
}