数据库显示

来源:互联网 发布:visio2013网络图标库 编辑:程序博客网 时间:2024/05/18 13:07
final SimpleAdapter adapter = new SimpleAdapter(this, getData(),
R.layout.mainlayout, new String[] { "text", "time", "image" },
new int[] { R.id.PL_TextView01, R.id.PL_TextView02,
R.id.PL_ImageView01 });
lv.setAdapter(adapter);


private List<Map<String, Object>> getData() {
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
Map<String, Object> map = new HashMap<String, Object>();

Cursor cur = DR.query("DB", new String[] { "text", "time" }, null,
null, null, null, "time desc");
while (cur.moveToNext()) {
for (int i = 0; i < cur.getCount(); i++) {
cur.moveToPosition(i);
String text = cur.getString(0);
String time = cur.getString(1);

map = new HashMap<String, Object>();

map.put("text", text);
map.put("time", time);
map.put("image", R.drawable.ic_menu_close_clear_cancel);
list.add(map);
}
}

return list;
}

原创粉丝点击