“orientation | keyboardHidden”没有调用onConfigurationChanged

时间:2011-01-11 09:49:12

标签: android android-configchanges

我想知道键盘关闭的时间,所以我正在使用android:configChanges="orientation|keyboardHidden"。我必须覆盖该方法  onConfigurationChanged,但似乎没有任何事情发生。我做错了吗?

2 个答案:

答案 0 :(得分:1)

观看日期,可能你有一个问题的解决方案,否则:

以下是我对另一个相关问题的回复:Is there a way to tell if the soft-keyboard is shown?

但是我在这里复制了一部分回复以避免死链接:

以下是具体的示例

检查是否有更好的理解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();
    }
}

我希望这可以帮到你

答案 1 :(得分:0)

您是否在重写方法中添加了super.onConfigurationChanged(newConfig);