点击别处隐藏输入法的方法
@Override
public boolean onTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
if (this.getCurrentFocus() != null) {
if (this.getCurrentFocus().getWindowToken() != null) {
InputMethodManager im =(InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
im.hideSoftInputFromWindow(this.getCurrentFocus().getWindowToken(),
InputMethodManager.HIDE_NOT_ALWAYS);
}
}
}
return super.onTouchEvent(event);
}
参考文献:
1、http://www.cnblogs.com/changjl/p/4175539.html
2、http://8407832.blog.51cto.com/8397832/1403478