Example usage for android.view ContextMenu setGroupEnabled

List of usage examples for android.view ContextMenu setGroupEnabled

Introduction

In this page you can find the example usage for android.view ContextMenu setGroupEnabled.

Prototype

public void setGroupEnabled(int group, boolean enabled);

Source Link

Document

Enable or disable all menu items that are in the given group.

Usage

From source file:org.videolan.vlc.gui.audio.AudioBrowserFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    MenuInflater inflater = getActivity().getMenuInflater();
    inflater.inflate(R.menu.audio_list_browser, menu);

    if (v.getId() != R.id.songs_list) {
        menu.setGroupEnabled(R.id.songs_view_only, false);
        menu.setGroupEnabled(R.id.phone_only, false);
    }//from www.java2s  .  com
    if (!Util.isPhone())
        menu.setGroupVisible(R.id.phone_only, false);
}

From source file:org.bombusim.lime.fragments.RosterFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {

    super.onCreateContextMenu(menu, v, menuInfo);

    int pos = ((AdapterContextMenuInfo) menuInfo).position;

    contextItem = getListAdapter().getItem(pos);

    if (contextItem instanceof RosterGroup) {
        //TODO: context menu for group
        return;/*w w  w  .j a  v a  2  s.  com*/
    }
    if (contextItem instanceof XmppAccount) {
        //TODO: context menu for account
        return;
    }

    if (contextItem instanceof Contact) {
        Contact c = (Contact) contextItem;
        menu.setHeaderTitle(c.getScreenName());

        Drawable icon = new BitmapDrawable(c.getAvatar());
        menu.setHeaderIcon(icon);

        MenuInflater inflater = getActivity().getMenuInflater();

        if (contextItem instanceof SelfContact) {
            inflater.inflate(R.menu.contact_self_menu, menu);
        } else {
            inflater.inflate(R.menu.contact_menu, menu);
        }

        //enable items available only if logged in
        menu.setGroupEnabled(R.id.groupLoggedIn, sb.isLoggedIn(c.getRosterJid()));
        return;
    }
}