如何键入的EditText android系统后隐藏键盘? [英] how to hide keyboard after typing in EditText in android?

查看:124
本文介绍了如何键入的EditText android系统后隐藏键盘?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个的TextView 键,按键排列于母公司的底部。

I have a TextView and button aligned to parent's bottom.

当我在它和$ P $输入文字PSS按钮来保存数据,虚拟键盘不会消失。

When I enter text in it and press the button to save data, the virtual keyboard does not disappear.

任何一个可以指导我如何隐藏键盘?

Can any one guide me how to hide the keyboard?

推荐答案

这应该工作。

InputMethodManager inputManager = 
        (InputMethodManager) context.
            getSystemService(Context.INPUT_METHOD_SERVICE); 
inputManager.hideSoftInputFromWindow(
        this.getCurrentFocus().getWindowToken(),
        InputMethodManager.HIDE_NOT_ALWAYS); 

只要确保this.getCurrentFocus()没有返回null,它会如果没有具有焦点。

Just make sure that this.getCurrentFocus() does not return null, which it would if nothing has focus.

这篇关于如何键入的EditText android系统后隐藏键盘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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