如何使 localtime.now 成为自动更新的连续函数?
how to make localtime.now a continuous function that updates automatically?
正如标题所说,我怎样才能使 LocalTime.now 持续更新,基本上变成一个时钟?
var current = LocalTime.now()
Current.text = current.toString()
//Current is the textView id in xml
// this currently prints out what the local time is at app launch.
使用TextClock
显示时间并自动更新您无需执行任何操作,请参阅详细信息。
<TextClock
android:id="@+id/textClock"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:format12Hour="hh:mm:ss a" />
https://developer.android.com/reference/android/widget/TextClock.html
正如标题所说,我怎样才能使 LocalTime.now 持续更新,基本上变成一个时钟?
var current = LocalTime.now()
Current.text = current.toString()
//Current is the textView id in xml
// this currently prints out what the local time is at app launch.
使用TextClock 显示时间并自动更新您无需执行任何操作,请参阅详细信息。
<TextClock
android:id="@+id/textClock"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:format12Hour="hh:mm:ss a" />
https://developer.android.com/reference/android/widget/TextClock.html