• 游客,欢迎来到米坛社区。
    米坛社区是大型中文智能穿戴设备交流社区,在这里交流你的极客思想,共同建造我们的智能世界
    为了更加方便的获取支持与帮助,请加入米坛社区官方QQ频道

讨论 How to change text every second?

amongus1

LV0
普通成员
UID
100950
2022-07-26
41
8
let __$$app$$__ = __$$hmAppManager$$__.currentApp; __$$module$$__ = __$$app$$__.current; let timeSensor = null; let textWidget = null; __$$module$$__.module = DeviceRuntimeCore.Page({ onInit() { timeSensor = hmSensor.createSensor(hmSensor.id.TIME) textWidget = hmUI.createWidget(hmUI.widget.TEXT, { x: 15, y: 200, w: DEVICE_WIDTH - 42 * 2, h: 42, color: 0xffffff, text_size: 24, align_h: hmUI.align.CENTER_H, align_v: hmUI.align.CENTER_V, text_style: hmUI.text_style.NONE, text: `${timeSensor.second}` }) textWidget.addEventListener(hmUI.event.CLICK_DOWN, (info) => { textWidget.setProperty(hmUI.prop.MORE, { y: 200 }) }) }, onShow() { }, onDestroy() { // On destroy, remove if not required } });

I am trying to set the text to timeSensor.second. however, it only happens once. How do I fix this
 

晚枝颂禾意

LV0
普通成员
UID
678509
2024-03-20
1
0
let __$$app$$__ = __$$hmAppManager$$__.currentApp; __$$module$$__ = __$$app$$__.current; let timeSensor = null; let textWidget = null; __$$module$$__.module = DeviceRuntimeCore.Page({ onInit() { timeSensor = hmSensor.createSensor(hmSensor.id.TIME) textWidget = hmUI.createWidget(hmUI.widget.TEXT, { x: 15, y: 200, w: DEVICE_WIDTH - 42 * 2, h: 42, color: 0xffffff, text_size: 24, align_h: hmUI.align.CENTER_H, align_v: hmUI.align.CENTER_V, text_style: hmUI.text_style.NONE, text: `${timeSensor.second}` }) textWidget.addEventListener(hmUI.event.CLICK_DOWN, (info) => { textWidget.setProperty(hmUI.prop.MORE, { y: 200 }) }) }, onShow() { }, onDestroy() { // On destroy, remove if not required } });

I am trying to set the text to timeSensor.second. however, it only happens once. How do I fix this
厉害
 

*这是一则由 Google AdSense 自动推荐的广告,与本站无关,不对其真实性与可靠性负责