更新android中的相对时间 [英] Updating the relative time in android
问题描述
我正在开发一个 Twitter 客户端应用程序.与其他推特客户端一样,我想显示推文相对于当前时间的相对时间.我正在使用一个列表视图和一个简单的适配器,它绑定到一个存储推文信息的数组列表.如果我计算相对时间并存储一个字符串,我将只存储永远不会更新的静态数据.我应该如何更新这些数据?有没有办法做到这一点?
I am developing a Twitter client application. As with other twitter clients, I would like to display the relative time of tweet with respect to the current time. I am using a list view and a Simple adapter that binds to an arraylist which stores the tweet information. If I calculate the relative time and store a string, I will be just storing static data which will never get updated. How should I update this data?? Is there any way to do this?
推荐答案
您必须每 X 秒在适配器上合并一次重新计算.如果您更新适配器,列表视图也会自行更新.
You will have to incorporate on your adapter a recalculation every X seconds. And if you update your adapter, the listview will update itself too.
这篇关于更新android中的相对时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!