onInputShowListener Android的 - 它是可能的,如果显示的软键盘来检测? [英] onInputShowListener Android - Is it possible to detect if any soft keyboard is shown?

查看:148
本文介绍了onInputShowListener Android的 - 它是可能的,如果显示的软键盘来检测?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在固定我的Andr​​oid应用程序的另一个问题后,我来到了另一件事。

after fixing another problem in my Android Application, i came to another thing.

这将是我可以做一些事情,比如隐藏一些视觉元素,如果SoftKeyboard所以像刷卡或正常的Andr​​oid键盘输入一个显示是很重要的。

It would be important that i can do something, like hide some visual elements, if the SoftKeyboard so a Input like Swipe or the normal Android Keyboard is shown.

我试过onConfigurationChange =KeyboardShow(伪code),但并没有改变得到事件时,例如Skype的得到显示。

I've tried the onConfigurationChange="KeyboardShow" (pseudocode) but had no change to get a event when for example skype got shown.

所以,现在我的问题是,是否有任何解决方案或功能或听众,与我能处理这样的行动?

So now my question is, is there any solution or function or listener, with which i can handle such a action?

我希望有人能帮助我。

I hope someone can help me.

诚恳,
迈克·朋兹

Sincerly, Mike Penz

推荐答案

有可能是更好的方法,但可能是添加:的android:configChanges =keyboardHidden到清单。这将触发与任何键盘的变化,所以你需要查询配置对象

There might be better approaches, but a possibility is to add: android:configChanges="keyboardHidden" to the manifest. That will fire with any keyboard changes, so the you will need to query the Configuration object

static Configuration prevConf = Configuration();
static int ignoreMasks = Configuration.HARDKEYBOARDHIDDEN_NO|Configuration.HARDKEYBOARDHIDDEN_YES;

onCreate() {
   prevConf = setToDefaults();
}
// all your code here

@Override
public void onConfigurationChanged (Configuration newConfig) {
    int deltas = newConfig.diff (prevConf); // what changed?
    prevConf = newConfig;

    if (delta & ignoreMasks) 
        return; // you're not interested in hard keyboards.

    //  your code here 
}

我吮吸位运算,所以你可能需要努力解决这一问题。

I suck at bitwise operators, so you might need to work around that.

这是API文档:

http://developer.android.com/reference/android/ R.attr.html#configChanges

<一个href=\"http://developer.android.com/reference/android/app/Activity.html#onConfigurationChanged%28android.content.res.Configuration%29\" rel=\"nofollow\">http://developer.android.com/reference/android/app/Activity.html#onConfigurationChanged%28android.content.res.Configuration%29

http://developer.android.com/reference/android/内容/ RES / Configuration.html

这篇关于onInputShowListener Android的 - 它是可能的,如果显示的软键盘来检测?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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