Android 软键盘点击Done隐藏软键盘

前言
         欢迎大家我分享和推荐好用的代码段~~
声明
         欢迎转载,但请保留文章原始出处:
         CSDN
http://www.csdn.net
         雨季o莫忧离:http://blog.csdn.net/luckkof

正文

 

public TextView mTextView;
mTextView.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); 
        //隐藏软键盘
               return true; 
           } 
    return false;
   }});


你可能感兴趣的:(Android)