代码如下:
@Override
public boolean onTouchEvent(MotionEvent event) {
InputMethodManager imm= (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
// TODO Auto-generated method stub
if (event.getAction() == MotionEvent.ACTION_DOWN) {
System.out.println("down");
if (MainActivity.this.getCurrentFocus() != null) {
if (MainActivity.this.getCurrentFocus().getWindowToken() != null) {
imm.hideSoftInputFromWindow(MainActivity.this.getCurrentFocus().getWindowToken(),
InputMethodManager.HIDE_NOT_ALWAYS);
}
}
}
return super.onTouchEvent(event);
}