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.
精彩评论