Android隐藏输入法

输入法隐藏两种方式:

/**
* 隐藏输入法
*
* @param myActivity
*/
public static void hideInput(Activity myActivity,EditText et)
{
  if(et==null)
  {
    ((InputMethodManager) myActivity.getSystemService(Activity.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(myActivity.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
  }
  else
  {
    InputMethodManager inputMethodManager = (InputMethodManager) myActivity.getApplicationContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    inputMethodManager.hideSoftInputFromWindow(et.getWindowToken(), 0); 
  }
}

posted @ 2014-06-27 09:47  陈苏乾  阅读(898)  评论(0编辑  收藏  举报