【发布时间】:2018-10-02 16:25:18
【问题描述】:
我正在尝试获取列出一年中周数的数据库列的第一天和最后一天。我可以将所有星期都提取到一个列表中,但我想像每月的第一天和最后一天一样列出它。例如:我有一年中的“39”和“40”周。我想在“24 sep - 30 oct”和“1 oct - 7 oct”之类的列表视图中显示它。
我使用此查询和 SimpleCursorAdapter 显示到列表视图中:
String query = "SELECT _id, semana_ano, SUM(valor_uber) AS valor FROM uber_records GROUP BY semana_ano ORDER BY semana_ano";
Cursor cursor = db.rawQuery(query, null);
cursor.moveToFirst();
Calendar c = Calendar.getInstance();
c.get(Calendar.MONTH);
String[] from = {"week_year", "value"};
int[] to = {R.id.week,R.id.value};
ListAdapter adapter = new SimpleCursorAdapter(ReportWeek.this,
R.layout.report_week,
cursor,from,to);
listview.setAdapter(adapter);
【问题讨论】: