“方向|键盘隐藏”;不调用onConfigurationChanged [英] "orientation|keyboardHidden" not calling onConfigurationChanged

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

问题描述

我想知道何时关闭键盘,所以我正在使用 android:configChanges = orientation | keyboardHidden 。我必须重写方法
onConfigurationChanged ,但是似乎什么也没有发生。我做错什么了吗?

I want to know when the keyboard is closed, so I'm using android:configChanges="orientation|keyboardHidden". I have to override the method onConfigurationChanged, but nothing seems to happen. Am I doing something wrong?

推荐答案

监视日期,可能您有解决问题的方法,否则:

watching the date , possibly you have a solution for your question, otherwise:

这是我对另一个相关问题的相同回答:有没有办法判断是否显示了软键盘?

Here is the same response i made to another question related : Is there a way to tell if the soft-keyboard is shown?

但我在此处复制了部分响应以避免死链接:

but i copy a portion of the response here to avoid dead links:

这是特定的样本

检查以更好地理解 http: //developer.android.com/guide/topics/resources/runtime-changes.html

    
@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);

    // Checks the orientation of the screen
    if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
        Toast.makeText(this, "landscape", Toast.LENGTH_SHORT).show();
    } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT){
        Toast.makeText(this, "portrait", Toast.LENGTH_SHORT).show();
    }
    // Checks whether a hardware keyboard is available
    if (newConfig.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO) {
        Toast.makeText(this, "keyboard visible", Toast.LENGTH_SHORT).show();
    } else if (newConfig.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_YES) {
        Toast.makeText(this, "keyboard hidden", Toast.LENGTH_SHORT).show();
    }
}

希望对您有所帮助

这篇关于“方向|键盘隐藏”;不调用onConfigurationChanged的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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