1、首先监听setOnTouchListener按下的操作,且要在ACTION_DOWN下的情况下返回 true
ed_test = (EditText) findViewById(R.id.ed_test);
ed_test.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
InputMethodManager manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
if(event.getAction() == MotionEvent.ACTION_DOWN){
if(getCurrentFocus()!=null && getCurrentFocus().getWindowToken()!=null){
manager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}
ed_test.requestFocus();//强制使其获取焦点
}
return true;
}
});