在这里查看Android文档:
https://developer.android.com/training/keyboard-input/style.html,
具体是:
EditText editText = (EditText) findViewById(R.id.search);
editText.setOnEditorActionListener(new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
boolean handled = false;
if (actionId == EditorInfo.IME_ACTION_SEND) {
sendMessage();
handled = true;
}
return handled;
}
});
单击“发送”按钮后,这不会关闭键盘。如果handled
设置为false
,它也不会关闭键盘。
在这种情况下隐藏键盘的适当方法是什么?
观察: -
how to hide keyboard after typing in EditText in android?,似乎有很多种方式。这真的是Android的方式吗?