歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> 捕獲Android文本輸入框的軟鍵盤完成(Done)按鍵消息

捕獲Android文本輸入框的軟鍵盤完成(Done)按鍵消息

日期:2017/3/1 11:01:51   编辑:Linux編程

捕獲Android文本輸入框的軟鍵盤完成(Done)按鍵消息:

  1. mEditText.setOnEditorActionListener(new EditText.OnEditorActionListener() {
  2. @Override
  3. public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
  4. if (actionId == EditorInfo.IME_ACTION_DONE) {
  5. InputMethodManager imm = (InputMethodManager)v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
  6. imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
  7. doSomething();
  8. return true;
  9. }
  10. return false;
  11. }
  12. });
Copyright © Linux教程網 All Rights Reserved