【发布时间】:2010-08-14 14:20:56
【问题描述】:
我需要在 ListView/ListActivity 中显示 SQL 连接的结果。
我已经创建了一个光标:
Cursor cursor = db.rawQuery(LIST_JOIN_SQL, null);
如果我遍历光标,结果正是我所期望的。但是,当我尝试使用 SimpleCursorAdapter 在 ListView 中显示这些结果时,我得到一个运行时异常,因为没有名为“id”的列。
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
R.layout.item, cursor, FROM, TO);
其中 FROM 和 TO 定义为:
private static String[] FROM = { "name", };
private static int[] TO = { R.id.name, };
现在我想我可能在这里使用了错误的方法,因为 SimpleCursorAdapters 似乎不适合显示连接结果。
您会在这里推荐什么方法?我只能使用 Android 1.6 API。
【问题讨论】:
标签: android sqlite listview cursor listactivity