Android点击空白区域隐藏键盘
2018-07-20 来源:open-open
/**
* 点击空白区域隐藏键盘.
* @param event the event
* @return true, if successful
*/
@Override
public boolean onTouchEvent(MotionEvent event) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
if (event.getAction() == MotionEvent.ACTION_DOWN) {
if (EBDocuSearchActivity.this.getCurrentFocus() != null) {
if (EBDocuSearchActivity.this.getCurrentFocus().getWindowToken() != null) {
imm.hideSoftInputFromWindow(EBDocuSearchActivity.this.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}
}
}
return super.onTouchEvent(event);
}
/**隐藏键盘 */
protected void hideInputKeyboard(View v) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
}
/**弹起键盘 */
protected void showInputKeyboard(View v) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(v, 0);
}
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点!
本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。
上一篇:几个有用的shell脚本
下一篇:Android开发常用代码片段
最新资讯
热门推荐