android点击空白区域隐藏软键盘的实现
16lz
2021-01-23
代码如下:
@Overridepublic boolean onTouchEvent(MotionEvent event) {InputMethodManager imm= (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);// TODO Auto-generated method stubif (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);}
更多相关文章
- android webview显示HTML代码
- Android 获取电池基本信息代码
- android 打开新浪微博代码
- Android 中如何自己通过代码绘图
- android 使用代码实现 RelativeLayout布局
- android 亮屏及屏幕解锁代码
- Android屏蔽home键的代码,咋摁也不响应的方法
- Android6.0 Audio系统代码流程
- 如何下载Android kernel内核源代码,编译烧写验证