Example usage for android.view View showContextMenu

List of usage examples for android.view View showContextMenu

Introduction

In this page you can find the example usage for android.view View showContextMenu.

Prototype

public boolean showContextMenu() 

Source Link

Document

Shows the context menu for this view.

Usage

From source file:org.brandroid.openmanager.activities.OpenExplorer.java

public boolean showMenu(final Menu menu, final View from, final boolean fromTouch) {
    if (from != null) {
        if (showIContextMenu(menu, from, fromTouch) == null) {
            from.setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() {
                public void onCreateContextMenu(ContextMenu cmenu, View v, ContextMenuInfo menuInfo) {
                    MenuUtils.transferMenu(menu, cmenu, false);
                }/*w  w w .ja  va 2 s  .  c o m*/
            });
            return from.showContextMenu();
        } else
            return true;
    } else
        openOptionsMenu();
    return false;
}

From source file:org.brandroid.openmanager.activities.OpenExplorer.java

public boolean showMenu(int menuId, final View from, final boolean fromTouch) {
    if (!BEFORE_HONEYCOMB && MenuUtils.getMenuLookupSub(menuId) > -1)
        return false;
    Logger.LogInfo("showMenu(0x" + Integer.toHexString(menuId) + "," + (from != null ? from.toString() : "NULL")
            + ")");
    //if(mMenuPopup == null)
    switch (menuId) {
    //case R.menu.content:
    case R.id.menu_more:
        if (showIContextMenu(mMainMenu, from instanceof CheckedTextView ? null : from, fromTouch) != null)
            return true;
        return true;
    }/*from  w w w  .j ava2 s  . c  o  m*/

    if (from != null && !(from instanceof CheckedTextView)
            && showIContextMenu(menuId, from instanceof CheckedTextView ? null : from, fromTouch) != null)
        return true;
    if (from.showContextMenu())
        return true;
    //if(IS_DEBUG_BUILD && BEFORE_HONEYCOMB)
    //   showToast("Invalid option (0x" + Integer.toHexString(menuId) + ")" + (from != null ? " under " + from.toString() + " (" + from.getLeft() + "," + from.getTop() + ")" : ""));
    return false;
}

From source file:org.brandroid.openmanager.activities.OpenExplorer.java

@Override
public void onClick(View v) {
    super.onClick(v);
    if (v == null)
        return;/*w w  w .j a  va  2  s. c  o  m*/
    int id = v.getId();
    if (id == R.id.menu_more) {
        if (USE_PRETTY_MENUS && showIContextMenu(mOptsMenu, v, true) != null)
            return;
    }
    if (v.getTag() instanceof Menu && ((Menu) v.getTag()).size() > 0) {
        if (USE_PRETTY_MENUS && showIContextMenu((Menu) v.getTag(), v, true) != null)
            return;
    }
    OpenFragment f = getSelectedFragment();
    if (f != null && f.onClick(id, v))
        return;
    if (v.getTag() != null && v.getTag() instanceof MenuItem && id != ((MenuItem) v.getTag()).getItemId()) {
        id = ((MenuItem) v.getTag()).getItemId();
        if (f.onClick(id, v))
            return;
        if (MenuUtils.getMenuLookupID(id) > -1 && showMenu(MenuUtils.getMenuLookupSub(id), v, true))
            return;
    }
    if (USE_PRETTY_MENUS || !v.showContextMenu())
        onClick(id, null, v);
}

From source file:android.app.Activity.java

/**
 * Programmatically opens the context menu for a particular {@code view}.
 * The {@code view} should have been added via
 * {@link #registerForContextMenu(View)}.
 * //from   ww w.java  2 s. c  o  m
 * @param view The view to show the context menu for.
 */
public void openContextMenu(View view) {
    view.showContextMenu();
}