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:Main.java

public static ProgressDialog showProgressDialog(Context context) {
    ProgressDialog myProgressDialog = new ProgressDialog(context);
    myProgressDialog.setMessage("Please wait...");
    myProgressDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    myProgressDialog.show();/*  ww  w .  j av  a2s .c om*/
    myProgressDialog.setCancelable(false);
    myProgressDialog.setOnKeyListener(new DialogInterface.OnKeyListener() {

        public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_SEARCH && event.getRepeatCount() == 0) {
                return true;
            }
            return false;
        }

    });
    return myProgressDialog;
}

From source file:Main.java

public static void createNonCancellableAcceptOrCancelDialog(Context context, String title, String message,
        String acceptButtonText, String cancelButtonText, final Runnable onAccept, final Runnable onCancel) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setCancelable(false);/*  w w  w.j a  v a2  s  . c o m*/
    builder.setTitle(title);
    builder.setMessage(message);
    builder.setInverseBackgroundForced(true);
    builder.setPositiveButton(acceptButtonText, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
            if (onAccept != null)
                onAccept.run();
        }
    });

    builder.setNegativeButton(cancelButtonText, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
            if (onCancel != null)
                onCancel.run();
        }
    });
    AlertDialog alert = builder.create();
    alert.setOnKeyListener(new DialogInterface.OnKeyListener() {
        @Override
        public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_SEARCH && event.getRepeatCount() == 0) {
                return true; // Pretend we processed it
            }
            return false; // Any other keys are still processed as normal
        }
    });
    alert.show();
}

From source file:com.btmura.android.reddit.app.GlobalMenuActivity.java

@Override
public boolean onKeyUp(int keyCode, @NonNull KeyEvent event) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_SEARCH:
        GlobalMenuFragment frag = getGlobalMenuFragment();
        if (frag != null) {
            frag.handleSearch();/*from www  .  j a v a2  s .  c o  m*/
            return true;
        }

    default:
        return super.onKeyUp(keyCode, event);
    }
}

From source file:net.kervala.comicsreader.PhotoViewActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_TAB:
    case KeyEvent.KEYCODE_SEARCH:
        showDialog(CommonActivity.DIALOG_PAGES);
        return true;
    case KeyEvent.KEYCODE_BACK:
        if (mAlbum != null) {
            setResult(CommonActivity.RESULT_FILE);
            //            String mimeType = mAlbum.getMimeType();
            //            Intent intent = getIntent();
            //            intent.setDataAndType(mAlbum.getAlbumUri(), mimeType);
            //            setResult(RESULT_FILE, intent);
        }/*from   w  w  w. ja v  a2 s.c o  m*/
        finish();
        return true;
    }

    return super.onKeyDown(keyCode, event);
}

From source file:net.lp.actionbarpoirot.actions.NavigateUpUiAction.java

@Override
public boolean onKeyUp(int keyCode, KeyEvent event, C context) {
    if (keyCode == KeyEvent.KEYCODE_SEARCH) {
        execute(context);//  w  ww. j  a  v  a  2  s .com
        return true;
    }
    return false;
}

From source file:org.videolan.vlc.gui.tv.browser.BaseTvActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_SEARCH) {
        startActivity(new Intent(this, SearchActivity.class));
        return true;
    }//from w  ww.ja v  a 2  s  .  c o m
    return super.onKeyDown(keyCode, event);
}

From source file:com.dmbstream.android.activity.SearchResultsActivity.java

@Override
public boolean onKey(View view, int i, KeyEvent keyEvent) {
    switch (keyEvent.getKeyCode()) {
    case KeyEvent.KEYCODE_SEARCH:
    case KeyEvent.KEYCODE_ENTER:
        AnalyticsUtil.trackEvent(SearchResultsActivity.this, "SearchResults", "Enter", "Query", 0);
        search();//from  ww w  . j  a va  2s  .co  m
        return true;
    }
    return false;
}

From source file:com.docd.purefm.ui.activities.SearchActivity.java

@Override
public boolean onKeyUp(final int keyCode, @NonNull final KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_SEARCH) {
        this.onSearchClicked();
        return true;
    }//from  ww w  .  j a  v  a  2  s .c o m
    return super.onKeyUp(keyCode, event);
}

From source file:com.se.cronus.AbstractCActivity.java

/**
 * /*from   ww w. j  a  v a2  s.  c  o m*/
 */
protected void setUpOnClicks() {
    // extract soon
    item.setOnClickListener(this);
    search.setOnClickListener(this);
    refresh.setOnClickListener(this);
    searchTextV.setClickable(true);
    searchTextV.setOnKeyListener(new OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (event.getAction() != KeyEvent.ACTION_DOWN)
                return false;
            if (keyCode == KeyEvent.KEYCODE_ENTER) {
                // your necessary codes...
                onSearchClick();
                return true;
            }
            if (keyCode == KeyEvent.KEYCODE_SEARCH) {
                // your necessary codes...
                onSearchClick();
                return true;
            }
            return false;
        }
    });
    searchTextV.setOnClickListener(this);
}

From source file:uk.bcu.ItuneActivity.java

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_SEARCH) {
        onSearchRequested();/*from  w w w.j  av  a  2 s .c  o  m*/

        return true;

    }
    return false;
}