Example usage for android.view MenuItem setVisible

List of usage examples for android.view MenuItem setVisible

Introduction

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

Prototype

public MenuItem setVisible(boolean visible);

Source Link

Document

Sets the visibility of the menu item.

Usage

From source file:Main.java

public static void setMenuItemVisible(final Menu menu, final boolean visible, final int viewId) {
    final MenuItem v = menu.findItem(viewId);
    if (v != null) {
        v.setVisible(visible);
    }/*  ww  w .j ava 2  s. c  o  m*/
}

From source file:com.laevatein.internal.ui.helper.PhotoSelectionViewHelper.java

public static void updateSelectMenuState(MenuItem item, SelectedUriCollection collection, boolean drawerOpen) {
    if (item == null) {
        return;/* w w w. ja  v a  2 s  .  com*/
    }
    item.setVisible(!drawerOpen);
    item.setEnabled(!collection.isEmpty() && collection.isCountInRange());
}

From source file:it.scoppelletti.mobilepower.app.CommonMenuFragment.java

/**
 * Imposta la visibilità di tutte le voci comuni del menù.
 * /*from   w  ww .j  a va  2  s . co m*/
 * @param menu    Menù.
 * @param visible Indicatore di visibilità.
 */
public static void setMenuItemVisible(Menu menu, boolean visible) {
    MenuItem menuItem;

    menuItem = menu.findItem(R.id.cmd_buy);
    if (menuItem != null) {
        menuItem.setVisible(visible);
    }

    menuItem = menu.findItem(R.id.cmd_settings);
    menuItem.setVisible(visible);
    menuItem = menu.findItem(R.id.cmd_help);
    menuItem.setVisible(visible);
    menuItem = menu.findItem(R.id.cmd_about);
    menuItem.setVisible(visible);
}

From source file:org.droidupnp.Main.java

public static void setSearchVisibility(boolean visibility) {
    if (actionBarMenu == null)
        return;/*from  w  w w .j a  va2 s.  c  o  m*/

    MenuItem item = actionBarMenu.findItem(R.id.action_search);

    if (item != null)
        item.setVisible(visibility);
}

From source file:com.theelix.libreexplorer.FileManager.java

public static void setPasteVisible(Boolean visible) {
    MenuItem item = ((FileManagerActivity) mContext).mMenu.findItem(R.id.toolbar_menu_paste);
    item.setVisible(visible);

}

From source file:com.silentcircle.contacts.utils.HelpUtils.java

/**
 * Prepares the help menu item by doing the following.
 * - If the helpUrlString is empty or null, the help menu item is made invisible.
 * - Otherwise, this makes the help menu item visible and sets the intent for the help menu
 *   item to view the URL.//  w w w. ja va2s.  c  o  m
 *
 * @return returns whether the help menu item has been made visible.
 */
public static boolean prepareHelpMenuItem(Context context, MenuItem helpMenuItem, String helpUrlString) {
    if (TextUtils.isEmpty(helpUrlString)) {
        // The help url string is empty or null, so set the help menu item to be invisible.
        helpMenuItem.setVisible(false);

        // return that the help menu item is not visible (i.e. false)
        return false;
    } else {
        // The help url string exists, so first add in some extra query parameters.
        final Uri fullUri = uriWithAddedParameters(context, Uri.parse(helpUrlString));

        // Then, create an intent that will be fired when the user
        // selects this help menu item.
        Intent intent = new Intent(Intent.ACTION_VIEW, fullUri);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);

        // Set the intent to the help menu item, show the help menu item in the overflow
        // menu, and make it visible.
        helpMenuItem.setIntent(intent);
        MenuItemCompat.setShowAsAction(helpMenuItem, MenuItem.SHOW_AS_ACTION_NEVER);
        helpMenuItem.setVisible(true);

        // return that the help menu item is visible (i.e., true)
        return true;
    }
}

From source file:com.oliversride.wordryo.Utils.java

public static void setItemVisible(Menu menu, int id, boolean enabled) {
    MenuItem item = menu.findItem(id);
    item.setVisible(enabled);
}

From source file:com.mediatek.contacts.activities.ActivitiesUtils.java

public static void prepareVcsMenu(Menu menu, VcsController vcsController) {
    if (vcsController != null) {
        vcsController.onPrepareOptionsMenuVcs(menu);
    } else {/*from  w ww .ja v  a 2 s .  c om*/
        MenuItem item = menu.findItem(com.android.contacts.R.id.menu_vcs);
        if (item != null) {
            item.setVisible(false);
        }
    }
}

From source file:com.android.gallery3d.ui.MenuExecutor.java

private static void setMenuItemVisible(Menu menu, int itemId, boolean visible) {
    MenuItem item = menu.findItem(itemId);
    if (item != null)
        item.setVisible(visible);
}

From source file:com.dodo.wbbshoutbox.codebot.MainActivity.java

public static void updateMenu() {
    MenuItem item_login = menucopy.findItem(R.id.login);
    MenuItem item_logout = menucopy.findItem(R.id.logout);

    if (loggedIn == 1) {
        item_login.setVisible(false);
        item_logout.setVisible(true);//www .  ja  v  a2  s . com
    } else {
        item_login.setVisible(true);
        item_logout.setVisible(false);
    }
}