隐藏键盘

Posted 希小风

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了隐藏键盘相关的知识,希望对你有一定的参考价值。

首先获得软键盘Manager
  1. InputMethodManager manager manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);  
  2.   
  3.   
  4.   
  5.   
  6. @Override  
  7.  public boolean onTouchEvent(MotionEvent event) {  
  8.   // TODO Auto-generated method stub  
  9.   if(event.getAction() == MotionEvent.ACTION_DOWN){  
  10.      if(getCurrentFocus()!=null && getCurrentFocus().getWindowToken()!=null){  
  11.        manager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);  
  12.      }  
  13.   }  
  14.   return super.onTouchEvent(event);  
  15.  }

以上是关于隐藏键盘的主要内容,如果未能解决你的问题,请参考以下文章