2011-01-11 83 views

回答

0

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

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(); 
    } 
} 

我希望这可以帮助您

+0

softKeyboard显示/隐藏从未触发onConfigurationChanged() – fantouch 2014-09-13 09:43:00