首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在ResultReceiver中使用InputMethodManager#hideSoftInputFromWindow

如何在ResultReceiver中使用InputMethodManager#hideSoftInputFromWindow
EN

Stack Overflow用户
提问于 2015-01-09 10:16:54
回答 1查看 2.6K关注 0票数 2

我有一些密码:

代码语言:javascript
复制
inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0, new ResultReceiver(null) {
     @Override
     protected void onReceiveResult(int resultCode, Bundle resultData) {
          keyboardClosed();
     }
});

但是,在4.3仿真器上运行这个方法-- onReceiveResult()方法永远不会被调用。我肯定我做错了什么,但我看不出.

有人能向我提供一些细节,如何正确地做到这一点,或为什么它不起作用?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-04-25 09:55:27

如果ResultReceiver返回false,则不调用false

您可以检查此值:

代码语言:javascript
复制
boolean hide = inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0, new ResultReceiver(null) {
    @Override
    protected void onReceiveResult(int resultCode, Bundle resultData) {
       keyboardClosed();
    }
});
if (!hide) {
    // already hidden
    keyboardClosed();
}
票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27858333

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档