Tag: onconfigurationchanged

为什么不调用onConfigurationChanged?

我正在写一个代码,更改方向时更改TextView的文本我正在使用onConfigurationChanged()侦听器来更改文本 override fun onConfigurationChanged(newConfig: Configuration?) { super.onConfigurationChanged(newConfig) val orientation : Int = getResources().getConfiguration().orientation val oTag = "Orientation Change" if(orientation == (Configuration.ORIENTATION_LANDSCAPE)){ mytext?.setText("Changed to Landscape") Log.i(oTag, "Orientation Changed to Landscape") }else if (orientation == (Configuration.ORIENTATION_PORTRAIT)){ mytext?.setText("Changed to Portratit") Log.i(oTag, "Orientation Changed to Portratit") }else{ Log.i(oTag, "Nothing is coming!!") } } 但即使在Log中也没有任何反应 我也已经将这个属性添加到我的清单文件中的活动 android:configChanges="orientation" 我在这里错过了什么? 还有没有其他办法可以做到这一点?