0
从我main.java:的Android源码的ListView光标问题
Cursor c = db.getDue();
String[] columns = new String[] { "_id", "date" };
int[] to = new int[] { R.id.num, R.id.date };
SimpleCursorAdapter mAdapter = new SimpleCursorAdapter(this,
R.layout.lventer, c, columns, to);
ListView lv1 = (ListView)findViewById(R.id.ListView01);
lv1.setAdapter(mAdapter);
从我的数据库包装类:
public Cursor getDue() {
//String getdue = "SELECT * FROM tb1"; // this returns _id+date and displays them in the listview via the cursor adapter, defined above
String getdue = "SELECT _id, max(date) AS date FROM tb1 GROUP BY _id";// this only works if I remove the "date" bindings defined above, only letting me see the _id, i want to see both _id and date in the lit view.
return db.rawQuery(getdue,null);
如果我用的是第二选择statment那么它崩溃,除非我删除了“日期“从游标适配器/列表视图绑定,如果我这样做,那么它会显示列表视图中返回的_id,但我想在列表视图中看到_id和日期。
我被告知第二个语句可能会返回一个不同类型的日期因为最大函数(我不是很有识字能力,但是),但我认为sqlite与数据类型是松散的?任何人都可以帮忙,提前感谢。
**更新**这是不会工作2列FR列表视图中的命令:
SELECT _id, max(date) FROM jobs GROUP BY _id HAVING max(date) < (date-21)
对不起xandy我已经贴了不正确的查询到以上代码,请检查更新。 – brux 2010-11-23 04:41:11