如何隐藏通过点击一个EditText之外的虚拟键盘? [英] How to hide the virtual keypad by clicking outside of an EditText?

查看:221
本文介绍了如何隐藏通过点击一个EditText之外的虚拟键盘?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新的Andr​​oid开发。我的要求是,我想隐藏Android的虚拟键盘,当我点击一个EditText小部件的外侧。请帮助。

I am new to Android development. My requirement is that I want to hide the android virtual keypad when I click on the outside of an EditText widget. Please help.

推荐答案

要隐藏你可以执行以下code中的虚拟键盘:

To hide the virtual keyboard you can execute the following code:

InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);

简单地讲的 onTouchDown()方法里面的那个code的 OnTouchListener 这是联系在一起的父布局。

Simply put that code inside the onTouchDown() method of an OnTouchListener that is tied to the parent layout.

这篇关于如何隐藏通过点击一个EditText之外的虚拟键盘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆