Android问题:当使用SimpleCursorAdapter时,如何格式化其中一列
我正在尝试创建一个映射到数据库查询的列表,但是,数据库中的一个字段是时间戳,显示时应显示为“3月2日,星期三”之类的日期,而不是数据库中类似1299517239487之类的实际值 我可以通过重新表述查询或在执行查询后修饰光标来解决这个问题,但我更希望简单的光标适配器以这种特定的方式显示此列 有人知道怎么做吗 一些代码:Android问题:当使用SimpleCursorAdapter时,如何格式化其中一列,android,database,datetime,listview,simplecursoradapter,Android,Database,Datetime,Listview,Simplecursoradapter,我正在尝试创建一个映射到数据库查询的列表,但是,数据库中的一个字段是时间戳,显示时应显示为“3月2日,星期三”之类的日期,而不是数据库中类似1299517239487之类的实际值 我可以通过重新表述查询或在执行查询后修饰光标来解决这个问题,但我更希望简单的光标适配器以这种特定的方式显示此列 有人知道怎么做吗 一些代码: // the desired columns to be bound String[] columns = new String[] { DBHelper.COL_START_T
// 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);
为了解决这个问题,我希望能够在适配器中添加某种后处理器
谢谢 您可以使用的方法手动设置视图的值,但是会为每一列调用该值。这不会覆盖适配器中定义的映射吗?API说,如果您从bind方法返回false,那么适配器将尝试找出它。我假设它将覆盖您选择的内容,但是如果您返回false,它将使用默认映射。