Android 自定义列表视图问题 - 对于时间表,我可以更改文本颜色和大小吗?
我正在开发一个类似于公交车时刻表的项目。我很好奇一件事:有没有办法做这样的事情:
这就是我想要的列表视图的样子。我的想法是获取当前时间,然后根据当前时间显示第一辆巴士的出发时间。因此,如果现在是12:00 am/pm
,我想像这样显示下一班车于 12:15 出发。使文本具有不同的颜色并使其更大。
有什么想法或建议我该怎么做或者是否可以做类似的事情? 提前致谢!
I'm working on a project which is something like bus schedule.And I'm curious about one thing : Is there any way to do something like this :
This is how I want to look like my list view. My idea is to get the current time and than show when the first bus depending on current time is leaving. So if it's 12:00 am/pm
I want to show that the next bus is leaving at 12:15 like this.To make the text in different color and make it bigger.
Any ideas or suggestions how can I do that or is it possible to make something like that?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 listview 的自定义适配器,并从该类的 getview() 方法中检查您当前的时间,从中获取依赖时间。如果可用,则简单更改该列表行(文本视图)的文本和字体。谢谢。
use custom adapter for listview and from that class's getview() method just check your current time from that get the depend time. If It available then change the text and font of that list row (textview) simple. Thanks.
您可以将所需的项目设置为所选项目。然后在 onItemSelected 侦听器中,您可以更改其文本颜色和大小。还要在成员中维护当前选定的项目,以便您可以在取消选择时恢复其大小和颜色。
参考 :
http://developer.android.com/reference/android/widget/ AdapterView.OnItemSelectedListener.html
You can set the required item as selected item. Then in
onItemSelected
listener you can change its text color and size. Also maintain the current selected item in a member so that you can revert the size and color when it's unselected.Reference :
http://developer.android.com/reference/android/widget/AdapterView.OnItemSelectedListener.html