如果想点击哪个地方,然后让软键盘自动消失,就设置它
// 点击Activity中的任意位置,edittext焦距消失,软键盘隐藏 public void CloseKeyBoard() { direct_times_cast.clearFocus(); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(direct_times_cast.getWindowToken(), 0); direct_chase_number.clearFocus(); imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(direct_chase_number.getWindowToken(), 0); } public boolean onTouchEvent(MotionEvent event) { CloseKeyBoard(); return super.onTouchEvent(event); }
?
private EditText direct_times_cast, direct_chase_number; direct_times_cast = (EditText) findViewById(R.id.direct_times_cast); direct_chase_number = (EditText) findViewById(R.id.direct_chase_number);
?