AppWidget中的TextClock不响应任何函数调用

我正在为LG V20 / V10的信息部件工作,在第二个屏幕上运行(很容易添加一个:只需将您的类别设置为36864 / 0x9000)。 目前,我在RemoteViews布局中有一个电池视图和一个TextClock:

            

在我的代码中,我有这些函数,从onUpdate()调用每个小部件ID(在Kotlin中):

 private fun updateBattery(views: RemoteViews) { val level = mBatteryManager?.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY) val charging = mBatteryManager?.isCharging mBatteryState.updateState(level as Int, charging as Boolean) views.setImageViewResource(R.id.battery_view, mBatteryState.imageResource) var color = mPrefs?.getInt("battery_color", Color.WHITE) var showPercent = mPrefs?.getBoolean("show_percent", true) if (color == null) color = Color.WHITE if (showPercent == null) showPercent = true views.setInt(R.id.battery_view, "setColorFilter", color) views.setTextColor(R.id.battery_percent, color) if (showPercent) { views.setViewVisibility(R.id.battery_percent, View.VISIBLE) views.setTextViewText(R.id.battery_percent, mBatteryState.percent.toString() + "%") } else { views.setViewVisibility(R.id.battery_percent, View.GONE) } } private fun updateClock(views: RemoteViews) { var hour_24 = mPrefs?.getBoolean("24_hour", false) var amPm = mPrefs?.getBoolean("am_pm", true) var showDate = mPrefs?.getBoolean("show_date", false) var color = mPrefs?.getInt("clock_color", Color.WHITE) if (hour_24 == null) hour_24 = false if (amPm == null) amPm = true if (showDate == null) showDate = false if (color == null) color = Color.WHITE val format: CharSequence = if (showDate) "EE, d " else {""} + if (hour_24) "k" else {"h"} + ":mm" + if (amPm) " a" else {""} views.setCharSequence(R.id.clock_view, "setFormat12Hour", format) views.setCharSequence(R.id.clock_view, "setFormat24Hour", format) views.setTextColor(R.id.clock_view, color) } 

我有一个开始的服务,监听首选项更改并接收广播意图,每当发生任何事情时都会调用小部件的onUpdate()

一切工作正常在电池function:我可以使用配置活动来改变色调和百分比是否显示,并立即发生变化。 但是,无论什么原因,钟表function中的function似乎都没有做到。

当视图膨胀时,我已经设置了一个颜色,它仍然是白色的。 如果我改变格式,什么都不会发生。 就好像TextClock函数没有被实际调用一样。

我甚至检查过AOSP源代码,看起来应该允许RemoteViews对象使用这些方法: setFormat12Hour(CharSequence charSequence)

我做错了什么?

那么我知道了,我真的不知道为什么这样。 我注意到,当我添加另一个小部件到信息屏幕,它也没有响应变化。 所以我看了两个破碎的视图和一个工作视图(电池)之间的差异。

我发现电池视图被包含在一个LinearLayout中,你不知道它,在虚线LinearLayouts中包含TextClock和新的部件(和ImageView)解决了这个问题: