开发者

can i write my own event on android:imeOptions="actionSearch"?

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 butt开发者_运维问答on we use on android activity.

any help would be appriciated.


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;
    }
});


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜