我可以写在Android上我自己的事件:imeOptions =“actionSearch”?
-
25-09-2019 - |
题
我使用机器人:imeOptions = “actionSearch”
在EDITTEXT和我的问题是我可以写我自己的事件,如果用户按下搜索按钮上Softkeyboard?
actualy我想执行类似于按钮我们用机器人活动softkeyboard搜索按钮的功能。
任何帮助将appriciated。
解决方案
这是我最后使用:
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;
}
});
其他提示
在setOnEditorActionListener()
注册一个EditText
当用户轻敲软键盘上的动作按钮将被调用呼叫TextView.OnEditorActionListener
。
不隶属于 StackOverflow