Example usage for android.view KeyEvent KEYCODE_SEARCH

List of usage examples for android.view KeyEvent KEYCODE_SEARCH

Introduction

In this page you can find the example usage for android.view KeyEvent KEYCODE_SEARCH.

Prototype

int KEYCODE_SEARCH

To view the source code for android.view KeyEvent KEYCODE_SEARCH.

Click Source Link

Document

Key code constant: Search key.

Usage

From source file:com.android.mms.ui.MessageUtils.java

/**
 * Gets a search progress dialog.//from  w w w.  j  a va 2 s .co m
 * @param context the activity context.
 * @return the search progress dialog.
 */
public static NewProgressDialog getProgressDialog(Context context) {
    NewProgressDialog dialog = new NewProgressDialog(context);
    dialog.setCancelable(false);
    dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    dialog.setMessage(context.getString(R.string.refreshing));
    dialog.setMax(1); /* default is one complete */
    // ignore the search key, when searching we do not want the search bar come out.
    dialog.setOnKeyListener(new DialogInterface.OnKeyListener() {
        public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
            return (keyCode == KeyEvent.KEYCODE_SEARCH);
        }
    });
    return dialog;
}