捕獲Android文本輸入框的軟鍵盤完成(Done)按鍵消息:
- mEditText.setOnEditorActionListener(new EditText.OnEditorActionListener() {
-
- @Override
- public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
- if (actionId == EditorInfo.IME_ACTION_DONE) {
- InputMethodManager imm = (InputMethodManager)v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
- imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
-
- doSomething();
-
- return true;
- }
- return false;
- }
-
- });