我尝试使用数据库适配器创建listview,如下面tutorial中提到的那样:
但是当我更改数据库的结构时,listview没有显示。 这是实际的脚本:
try{
cursor = db.rawQuery("SELECT * FROM tum ORDER BY nama ASC", null);
adapter = new SimpleCursorAdapter(this, R.layout.isi_lv, cursor, new String[] {"nama", "nama_latin", "img"}, new int[] {R.id.tv_nama, R.id.tv_nama_latin, R.id.imV});
lv.setAdapter(adapter);
lv.setTextFilterEnabled(true);
}catch(Exception e){
e.printStackTrace();
}
这是我根据我之前制作的数据库制作的脚本
try{
dataCursor = db.rawQuery("SELECT * FROM tb_achievement", null);
adapter = new SimpleCursorAdapter(this, R.layout.isi_lv, dataCursor, new String[] {"title", "description", "img"}, new int[] {R.id.tv_title, R.id.tv_description, R.id.imV});
lv.setAdapter(adapter);
lv.setTextFilterEnabled(true);
lv.setOnItemClickListener(new OnItemClickListener() {
}catch(Exception e){
e.printStackTrace();
}
谢谢