Android kotlin 切换语言区域后 Activity onConfigurationChanged 没有监听到
可能是因为您的 Activity 没有设置 android:configChanges 属性。在您的 Activity 的 XML 布局文件中添加以下属性:
android:configChanges="locale"
这样就可以监听语言区域变化了。同时,您需要在 Activity 中重写 onConfigurationChanged 方法,如下:
override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)
// 处理语言区域变化
}
在该方法中,您可以处理语言区域变化的逻辑。
原文地址: https://www.cveoy.top/t/topic/dhH2 著作权归作者所有。请勿转载和采集!