use*_*180 3 android overriding android-fragments kotlin
我试图在继承自 Fragment 类的类中使用以下代码重载该函数来检测屏幕方向更改。
override fun onConfigurationChanged(newConfig: Configuration?) {
newConfig?.let { super.onConfigurationChanged(it) }
if (newConfig != null) {
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
Handler().postDelayed({
otrosScrollView.fullScroll(ScrollView.FOCUS_UP)
},600)
} else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
Handler().postDelayed({
otrosScrollView.fullScroll(ScrollView.FOCUS_UP)
},600)
}
}
}
Run Code Online (Sandbox Code Playgroud)
但它给出了 onConfigurationChanged 不覆盖任何内容的错误,因此不确定如何处理该问题。
我该怎么做才能让片段对上述事件做出反应?
| 归档时间: |
|
| 查看次数: |
824 次 |
| 最近记录: |