【发布时间】:2014-11-24 03:26:19
【问题描述】:
我正在尝试通过SimpleCursorAdapter 使用 SQL 中的表中的数据填充列表视图,但每次活动打开时,它都会使应用程序崩溃。由于某种原因,Android Studio 不允许我查看错误日志。有人可以告诉我这段代码到底有什么问题吗?它在我的onCreate 方法中。
db = openOrCreateDatabase("namesAndscoresAndtimes", SQLiteDatabase.CREATE_IF_NECESSARY, null);
c = db.query("namesAndscoresAndtimes", null, null, null, null, null, null);
String[] fromCols = { "name", "score", "time", "percentile" };
int[] toViews = { R.id.name, R.id.score, R.id.time, R.id.points };
SimpleCursorAdapter sca = new SimpleCursorAdapter(this, R.layout.scr, c, fromCols, toViews, 0);
ListView lv = (ListView) findViewById(R.id.scoretables);
lv.setAdapter(sca);
【问题讨论】:
-
你可以通过android studio中的“Android Device Monitor”看到Longcat。
标签: java android database listview simplecursoradapter