Example usage for android.app SearchManager MENU_KEY

List of usage examples for android.app SearchManager MENU_KEY

Introduction

In this page you can find the example usage for android.app SearchManager MENU_KEY.

Prototype

char MENU_KEY

To view the source code for android.app SearchManager MENU_KEY.

Click Source Link

Document

This is a shortcut definition for the default menu key to use for invoking search.

Usage

From source file:nl.sogeti.android.gpstracker.viewer.TrackList.java

/*******************************************************************/

@Override//  ww w .  jav a2s .c om
public boolean onCreateOptionsMenu(Menu menu) {
    boolean result = super.onCreateOptionsMenu(menu);
    MenuItem item;
    item = menu.add(ContextMenu.NONE, MENU_SEARCH, ContextMenu.NONE, android.R.string.search_go)
            .setIcon(R.drawable.ic_search_24dp).setAlphabeticShortcut(SearchManager.MENU_KEY);
    MenuItemCompat.setShowAsAction(item, MenuItem.SHOW_AS_ACTION_ALWAYS);
    item = menu.add(ContextMenu.NONE, MENU_PICKER, ContextMenu.NONE, R.string.menu_picker)
            .setIcon(R.drawable.ic_import_24dp);
    MenuItemCompat.setShowAsAction(item, MenuItem.SHOW_AS_ACTION_ALWAYS);
    item = menu.add(ContextMenu.NONE, MENU_VACUUM, ContextMenu.NONE, R.string.menu_vacuum)
            .setIcon(android.R.drawable.ic_menu_crop);
    MenuItemCompat.setShowAsAction(item, MenuItem.SHOW_AS_ACTION_NEVER);
    return result;
}

From source file:com.andybotting.tubechaser.activity.Home.java

/**
 * Create the options menu//from   w ww  . j  av a  2  s. co m
 */
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);

    menu.add(0, MENU_REFRESH, 0, R.string.menu_item_refresh).setIcon(R.drawable.ic_menu_refresh);

    menu.add(0, MENU_ABOUT, 0, R.string.menu_item_about).setIcon(android.R.drawable.ic_menu_help);

    menu.add(0, MENU_SETTINGS, 0, R.string.menu_item_settings).setIcon(android.R.drawable.ic_menu_preferences);

    menu.add(0, MENU_SEARCH, 0, R.string.menu_item_search)
            .setIcon(android.R.drawable.ic_search_category_default)
            .setAlphabeticShortcut(SearchManager.MENU_KEY);

    return true;
}

From source file:com.air.mobilebrowser.BrowserActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);

    //- Remove exit functionality, exit will be via javascript only.
    menu.add(0, 0, 0, "Exit").setIcon(android.R.drawable.ic_menu_close_clear_cancel)
            .setAlphabeticShortcut(SearchManager.MENU_KEY);

    /* Disabled Settings - Uncomment if needed (otherwise this will be removed later, along with the settings code) */
    /*// ww  w .j av a2 s  .  co  m
    menu.add(0, 1, 0, R.string.menu_settings)
    .setIcon(android.R.drawable.ic_menu_preferences)
    .setIntent(new Intent(android.provider.Settings.ACTION_SETTINGS));
     */

    return true;
}

From source file:com.cognizant.trumobi.PersonaLauncher.java

/**
 * Cancel search dialog if it is open.//w  ww. j  a  va2  s.  com
 */
/*
 * void stopSearch() { // Close search dialog SearchManager searchManager =
 * (SearchManager) getSystemService(Context.SEARCH_SERVICE);
 * searchManager.stopSearch(); // Restore search widget to its normal
 * position PersonaSearch searchWidget =
 * mWorkspace.findSearchWidgetOnCurrentScreen(); if (searchWidget != null) {
 * searchWidget.stopSearch(false); } }
 */

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    if (mDesktopLocked && mSavedInstanceState == null)
        return false;

    super.onCreateOptionsMenu(menu);
    menu.add(MENU_GROUP_ADD, MENU_ADD, 0, R.string.menu_add).setIcon(android.R.drawable.ic_menu_add)
            .setAlphabeticShortcut('A');
    menu.add(MENU_GROUP_NORMAL, MENU_SEARCH, 0, R.string.menu_search)
            .setIcon(android.R.drawable.ic_search_category_default)
            .setAlphabeticShortcut(SearchManager.MENU_KEY);
    menu.add(MENU_GROUP_NORMAL, MENU_NOTIFICATIONS, 0, R.string.menu_edit)
            .setIcon(android.R.drawable.ic_menu_edit).setAlphabeticShortcut('E');

    final Intent settings = new Intent(android.provider.Settings.ACTION_SETTINGS);
    settings.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);

    menu.add(MENU_GROUP_NORMAL, MENU_SETTINGS, 0, R.string.menu_settings)
            .setIcon(android.R.drawable.ic_menu_preferences).setAlphabeticShortcut('P').setIntent(settings);
    // ADW: add custom settings
    menu.add(MENU_GROUP_NORMAL, MENU_ALMOSTNEXUS, 0, R.string.menu_adw_settings)
            .setIcon(android.R.drawable.ic_menu_preferences).setAlphabeticShortcut('X');

    menu.add(MENU_GROUP_CATALOGUE, MENU_APP_GRP_CONFIG, 0, R.string.AppGroupConfig)
            .setIcon(android.R.drawable.ic_menu_agenda);
    // menu.add(MENU_GROUP_CATALOGUE, MENU_APP_GRP_RENAME, 0,
    // R.string.AppGroupRename)
    // .setIcon(R.drawable.ic_menu_notifications);
    menu.add(MENU_GROUP_CATALOGUE, MENU_APP_SWITCH_GRP, 0, R.string.AppGroupChoose)
            .setIcon(android.R.drawable.ic_menu_manage);
    menu.add(MENU_GROUP_CATALOGUE, MENU_APP_DELETE_GRP, 0, R.string.AppGroupDel)
            .setIcon(android.R.drawable.ic_menu_delete);
    menu.add(MENU_GROUP_NORMAL, MENU_LOCK_DESKTOP, 0, R.string.menu_lock)
            .setIcon(android.R.drawable.ic_menu_preferences).setAlphabeticShortcut('X');
    return true;
}