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:Main.java

public static void alwaysShowMenuItem(MenuItem add) {
    add.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
}

From source file:Main.java

public static void setShowAsAction(MenuItem item, int action) {
    if (Build.VERSION.SDK_INT >= 11) {
        item.setShowAsAction(action);
    }//from  www .  jav  a 2  s . co  m
}

From source file:Main.java

public static void setShowMenuAsAction(MenuItem menuItem, int actionEnum) {
    /* Action Bar is available since Android 3.0 (API level 11) */
    if (Build.VERSION.SDK_INT >= 11) {
        menuItem.setShowAsAction(actionEnum);
    }// w  w w  .ja  v  a  2s  . c  om
}

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

public static MenuItem getMenu(Context context, Menu menu) {
    if (menu == null || context == null) {
        return null;
    }//www . j  a v  a  2 s .  c om
    if (AccessibilityUtils.isEnabled(context)) {
        MenuItem mi = menu.add(Menu.NONE, R.id.menu_refresh, Menu.FIRST + 40, R.string.refresh);
        mi.setIcon(R.drawable.ic_refresh);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        return mi;
    } else {
        return null;
    }
}

From source file:com.anykey.balala.activity.BaseActivity.java

protected static void alwaysShowMenuItem(MenuItem add) {
    add.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
}

From source file:org.alfresco.mobile.android.application.fragments.workflow.process.ProcessesFragment.java

public static void getMenu(Context context, Menu menu) {
    MenuItem mi;

    mi = menu.add(Menu.NONE, R.id.menu_workflow_add, Menu.FIRST, R.string.workflow_start);
    mi.setIcon(android.R.drawable.ic_menu_add);
    mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

    MenuFragmentHelper.getMenu(context, menu);
}

From source file:com.arantius.tivocommander.Utils.java

@SuppressLint("NewApi")
final static void addToMenu(Menu menu, Activity activity, int itemId, int iconId, String title,
        int showAsAction) {
    if (Utils.activityForMenuId(itemId) == activity.getClass()) {
        return;// w  w  w.  ja va  2 s.com
    }
    MenuItem menuitem = menu.add(Menu.NONE, itemId, Menu.NONE, title);
    menuitem.setIcon(iconId);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        menuitem.setShowAsAction(showAsAction);
    }
}

From source file:org.alfresco.mobile.android.application.fragments.search.SearchFragment.java

public static void getMenu(Menu menu) {
    MenuItem mi = menu.add(Menu.NONE, R.id.menu_search_option, Menu.FIRST, R.string.search_advanced);
    mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
}

From source file:org.alfresco.mobile.android.application.fragments.person.PersonProfileFragment.java

public static void getMenu(Menu menu) {
    MenuItem mi = menu.add(Menu.NONE, MenuActionItem.MENU_PROFILE, Menu.FIRST + MenuActionItem.MENU_PROFILE,
            R.string.my_profile);//w  ww .  j av a  2 s  . c  om
    mi.setIcon(R.drawable.ic_avatar);
    mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
}

From source file:MainActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    MenuItem menuItem = menu.findItem(MENU_DOWNLOAD);
    menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    menuItem.setVisible(showDownloadMenu);
    return true;//from  ww  w . j av  a  2 s. c o m
}