如何删除键盘后,我做完一个活动? [英] How do I remove the keyboard after I finish an activity?

查看:130
本文介绍了如何删除键盘后,我做完一个活动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用户类型里面,然后单击确定按钮的活动。当它完成,该活动将关闭并返回到老的活动,但软键盘仍然是在屏幕上!我试过安卓windowSoftInputMode =stateHidden和         。getWindow()setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

I have an activity that users type inside and then click the ok button. When it is finished, the activity closes and goes back to the old activity but the soft keyboard is still on the screen! I've tried android:windowSoftInputMode="stateHidden" and getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

但不起任何作用。

感谢

推荐答案

在您的活动将OnPause,你应该做以下

In OnPause of your activity, you should do the following

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

在哪里等你的EditText的实例。

Where et is an instance of your EditText.

这篇关于如何删除键盘后,我做完一个活动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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