您的位置:首页 > 移动开发 > Android开发

Android单击界面上面的其他位置,取消焦点,让键盘消失

2015-09-19 00:46 423 查看
all=(RelativeLayout)findViewById(R.id.all);
all.setOnTouchListener(new OnTouchListener() {

@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO 自动生成的方法存根

all.setFocusable(true);
all.setFocusableInTouchMode(true);
all.requestFocus();
InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
return false;
}
});
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: