隐藏软键盘不灵 [英] Hide Soft Keyboard Not Working

查看:341
本文介绍了隐藏软键盘不灵的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发的Droid的难以置信(并测试了一个1.5 AVD模拟器为好),并在我的标签插件的一个选项卡包含一个ListView和一排一个EditText和一个发送按钮(对于聊天功能)。我使用下面的关闭软键盘,一旦我点击发送,但它不工作。这等同于code我在其他地方发现,人们已经upvoted是正确的。

I'm developing on the Droid Incredible (and have tested on a 1.5 AVD Emulator as well), and one of the tabs in my tab widget consists of a listview and a row with an EditText and a Send button (for a chat feature). I am using the following to close the soft keyboard once I click Send, but it's not working. This is identical to code I've found elsewhere that people have upvoted as correct.

看到什么我失踪?

// in Button's onClick():
EditText chatTextBox = (EditText) findViewById(R.id.chat_entry);
// Handle button click ...
chatTextBox.setText("");

InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(chatTextBox.getWindowToken(), InputMethodManager.HIDE_IMPLICIT_ONLY);

我也试图改变标志为0,没有运气。任何人都知道这是怎么回事?

I also tried changing the flag to 0. No luck. Anyone know what's up??

*的修改的* 刚刚意识到我原来用 hideSoftInputFromInputMethod()而不是 hideSoftInputFromWindow()。改变它没能正常工作,但...

*EDIT* Just realized I was originally using hideSoftInputFromInputMethod() instead of hideSoftInputFromWindow(). Changing it didn't make it work though...

推荐答案

更​​改HIDE_IMPLICIT_ONLY 0做到了(之后我改成 hideSoftInputFromWindow() hideSoftInputFromInputMethod())。

Changing HIDE_IMPLICIT_ONLY to 0 did it (after I changed tohideSoftInputFromWindow() from of hideSoftInputFromInputMethod()).

不过,我不知道为什么HIDE_IMPLICIT_ONLY不工作,因为我没有明确地在菜单上很长的preSS打开键盘。

However I'm not sure why HIDE_IMPLICIT_ONLY isn't working since I am not explicitly opening the keyboard with a long press on Menu.

这篇关于隐藏软键盘不灵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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