更新的TextView,每一分钟,在一分钟的最佳方式 [英] Best way to update TextView, every minute, on the minute

查看:153
本文介绍了更新的TextView,每一分钟,在一分钟的最佳方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是与此类似,如何更新窗口小部件每分钟,但我只想要更新的用户界面TextView的。我需要访问的时间,所以很遗憾不能简单地用DigitalClock视图。

My problem is similar to this one, How to update a widget every minute, however I only want to update TextView of the UI. I need access to the time so unfortunately can not simply use the DigitalClock view.

我一直研究和发现的方法来更新每一分钟,但不能在一分钟让它们与系统时钟同步(所以他们可能会高达59秒的同步!)

Ive been researching and have found ways to update every minute, but not on the minute so they are synchronised with the system clock (so they might be up to 59 seconds out of sync!)

的唯一途径我能想到这样做是 (一)运行的处理程序(或定时器)每秒(这似乎有点像杀鸡用牛刀,如果我只是想更新每分钟)的就像这起android.com资源

The only ways I can think to do it are (a) Run a handler (or timer) every second (which seems a bit like overkill if I only want to update every minute) Like this from the android.com resources

(二)有在后台运行的服务。 (我并不热衷于这个,因为我已经有了在后台运行更重要的事情)

(b) Have a service running in background. (I'm not keen on this as I already have more important things running in the background)

(三)使用报警管理器(又似乎有点小题大做)

(c) use Alarm Manager (again seems like overkill)

好像是这样一个容易的事,可是......

Seems to be such an easy thing to do, and yet...

任何意见AP preciated 梅尔

Any advice appreciated Mel

推荐答案

您可以尝试配置的定时器的运行的TimerTask 更新您的TextView的每分钟(见的<一个href="http://developer.android.com/reference/java/util/Timer.html#schedule%28java.util.TimerTask,%20java.util.Date,%20long%29"相对=nofollow>日程法)。

You can try configuring a Timer to run a TimerTask that updates your TextView every minute (see its schedule method).

这篇关于更新的TextView,每一分钟,在一分钟的最佳方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆