我正在开发一个电视指南应用程序,它使用一次ListActivity
显示一个频道/一天的电视节目。我正在RelativeLayout
为这些ListView
项目使用 a,我希望它ListView
看起来像这样:
07:00 The Breakfast Show
Latest news and topical reports
08:00 Tom and Jerry
More cat and mouse capers
ListView
我使用以下代码获取项目的数据:
Cursor cursor = db.rawQuery(SELECT blah,blah,blah);
String[] columnNames = new String[]{"start_time","title", "subtitle"};
int[] resIds = new int[]{R.id.start_time_short, R.id.title, R.id.subtitle};
adapter = new SimpleCursorAdapter(this, R.layout.guide_list_item, cursor, columnNames, resIds);
我的问题是该start_time
字段datetime
具有以下格式:
2011-01-23 07:00:00
所以我得到的是:
2011-01-23 07:00:00 The Breakfast Show
Latest news and topical reports
2011-01-23 08:00:00 Tom and Jerry
More cat and mouse capers
我想做的是使用SimpleDateFormat
( "HH:mm"
) 格式化上面的内容,所以我只得到该字段的hour:minute
一部分。start_time
我找到了SimpleCursor.ViewBinder
表明它可能是我想要的界面,但我不知道如何使用它。如果我是对的ViewBinder
,我会很感激一些关于如何使用它的示例代码的指针。否则,我还能如何实现将start_time
字段更改为简单地显示HH:mm
格式?