如何根据时间和日期更改文本? [英] How to change text based on time and date?

查看:218
本文介绍了如何根据时间和日期更改文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我需要两个选项之一,但不知道从哪里开始无论是。

So I need one of two options but don't know where to start with either.


  • 我有一个recyclerview列表卡的看法。每张卡片视图需要有倒计时实现并能​​同时运行。 (好像更难选项)或

  • I have a list card views in a recyclerview. Each card view needs to have countdown timer implemented and able to run simultaneously. (Seems like the harder option) OR

更新的基础上卡片视图中的文本,如果指定的时间或系统时间达到指定分钟和小时。

Update the text in a card view based on if a specified time has elapsed or system time reaches a specified minute and hour.

推荐答案

要使用不同的定时器,你需要做的线程卡。而在Android的最简单的方法是的AsyncTask 。所以你创建了一堆的AsyncTask S(可能你会希望有一个的ArrayList 来,你会添加的AsyncTask S),然后用一个简单的循环 .execute()他们。

To make the cards with different timers you will need threads. And the easiest way in Android is AsyncTask. So you create a bunch of AsyncTasks (probably you'd want an ArrayList to which you will add the AsyncTasks) and then with a cycle simply .execute() them.

作出的AsyncTask 是很容易的。您只需做一个从的AsyncTask 派生新类并实现 doInBackground()方法。

Making an AsyncTask is very easy. You simply make a new class that is derived from AsyncTask and implement the doInBackground() method.

P.S。如果你正在为Android 3.0及更高的发展,您将需要启动AsyncTasks这种方式:

P.S. If you're developing for Android 3.0 and higher you will need to launch AsyncTasks this way:

.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);

这会让他们同时运行

这篇关于如何根据时间和日期更改文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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