当前位置: 代码迷 >> Android >> Android问题:使用SimpleCursorAdapter时,如何格式化其中一列
  详细解决方案

Android问题:使用SimpleCursorAdapter时,如何格式化其中一列

热度:43   发布时间:2023-08-04 12:27:22.0

我正在尝试创建一个映射到数据库查询的列表,但是,数据库中的一个字段是时间戳记,在显示时应显示为“ 3月2日,星期三”之类的日期,而不是其中的实际值。该数据库类似于1299517239487 ...

我可以通过改写查询或在执行查询后装饰光标来解决此问题,但是我宁愿让简单的光标适配器以特定方式显示此列。

有谁知道如何做吗?

一些代码:

// the desired columns to be bound
String[] columns = new String[] { DBHelper.COL_START_TIME, DBHelper.COL_AMOUNT};
// the XML defined views which the data will be bound to
int[] to = new int[] { R.id.dayMonthDate, R.id.amount};

// create the adapter using the cursor pointing to the desired data as well as the layout information
SimpleCursorAdapter mAdapter = new SimpleCursorAdapter(this, R.layout.single_activity,cursor, columns, to);

我希望能够向适配器添加某种后处理器以修复该问题。

谢谢!

您可以使用的方法有手动设置值的意见,但将调用每列。

  相关解决方案