Question

i am using android:imeOptions="actionSearch"

in editText and my question is can i write my own event if user presses Searchbutton on Softkeyboard?

actualy i want to perform functionality of softkeyboard search button similar to button we use on android activity.

any help would be appriciated.

Was it helpful?

Solution

This is what I ended up using:

EditText SearchEditText = (EditText) findViewById(R.id.txtMapSearch);
SearchEditText.setOnEditorActionListener(new OnEditorActionListener() {
    @Override
    public boolean onEditorAction(TextView arg0, int arg1, KeyEvent arg2) {
        // TODO Auto-generated method stub
        if (arg1 == EditorInfo.IME_ACTION_SEARCH) {
            // search pressed and perform your functionality.
        }
        return false;
    }
});

OTHER TIPS

Call setOnEditorActionListener() on the EditText to register a TextView.OnEditorActionListener that will be invoked when the user taps the action button on the soft keyboard.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top