Example usage for android.view Window FEATURE_CONTEXT_MENU

List of usage examples for android.view Window FEATURE_CONTEXT_MENU

Introduction

In this page you can find the example usage for android.view Window FEATURE_CONTEXT_MENU.

Prototype

int FEATURE_CONTEXT_MENU

To view the source code for android.view Window FEATURE_CONTEXT_MENU.

Click Source Link

Document

Flag for the context menu.

Usage

From source file:com.chuhan.privatecalc.fragment.os.FragmentActivity.java

/**
 * Dispatch context and options menu to fragments.
 */// w w  w  . ja va  2s .c om
@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
    if (super.onMenuItemSelected(featureId, item)) {
        return true;
    }

    switch (featureId) {
    case Window.FEATURE_OPTIONS_PANEL:
        return mFragments.dispatchOptionsItemSelected(item);

    case Window.FEATURE_CONTEXT_MENU:
        return mFragments.dispatchContextItemSelected(item);

    default:
        return false;
    }
}

From source file:android.app.Activity.java

/**
 * Default implementation of/*from   w  ww .java 2s . co m*/
 * {@link android.view.Window.Callback#onMenuItemSelected}
 * for activities.  This calls through to the new
 * {@link #onOptionsItemSelected} method for the
 * {@link android.view.Window#FEATURE_OPTIONS_PANEL}
 * panel, so that subclasses of
 * Activity don't need to deal with feature codes.
 */
public boolean onMenuItemSelected(int featureId, MenuItem item) {
    CharSequence titleCondensed = item.getTitleCondensed();

    switch (featureId) {
    case Window.FEATURE_OPTIONS_PANEL:
        // Put event logging here so it gets called even if subclass
        // doesn't call through to superclass's implmeentation of each
        // of these methods below
        if (titleCondensed != null) {
            EventLog.writeEvent(50000, 0, titleCondensed.toString());
        }
        if (onOptionsItemSelected(item)) {
            return true;
        }
        if (mFragments.dispatchOptionsItemSelected(item)) {
            return true;
        }
        if (item.getItemId() == android.R.id.home && mActionBar != null
                && (mActionBar.getDisplayOptions() & ActionBar.DISPLAY_HOME_AS_UP) != 0) {
            if (mParent == null) {
                return onNavigateUp();
            } else {
                return mParent.onNavigateUpFromChild(this);
            }
        }
        return false;

    case Window.FEATURE_CONTEXT_MENU:
        if (titleCondensed != null) {
            EventLog.writeEvent(50000, 1, titleCondensed.toString());
        }
        if (onContextItemSelected(item)) {
            return true;
        }
        return mFragments.dispatchContextItemSelected(item);

    default:
        return false;
    }
}

From source file:android.app.Activity.java

/**
 * Default implementation of//from   w w  w.  j  a  v a 2s . co m
 * {@link android.view.Window.Callback#onPanelClosed(int, Menu)} for
 * activities. This calls through to {@link #onOptionsMenuClosed(Menu)}
 * method for the {@link android.view.Window#FEATURE_OPTIONS_PANEL} panel,
 * so that subclasses of Activity don't need to deal with feature codes.
 * For context menus ({@link Window#FEATURE_CONTEXT_MENU}), the
 * {@link #onContextMenuClosed(Menu)} will be called.
 */
public void onPanelClosed(int featureId, Menu menu) {
    switch (featureId) {
    case Window.FEATURE_OPTIONS_PANEL:
        mFragments.dispatchOptionsMenuClosed(menu);
        onOptionsMenuClosed(menu);
        break;

    case Window.FEATURE_CONTEXT_MENU:
        onContextMenuClosed(menu);
        break;

    case Window.FEATURE_ACTION_BAR:
        initActionBar();
        mActionBar.dispatchMenuVisibilityChanged(false);
        break;
    }
}

From source file:android.app.Activity.java

/**
 * Programmatically closes the most recently opened context menu, if showing.
 */
public void closeContextMenu() {
    mWindow.closePanel(Window.FEATURE_CONTEXT_MENU);
}