Cursor cursor=db.query("missing",new String[]{ "variety", "old ", "hair","where_from","flesh", "sex" },null,null,null,null,null);
List<Map<String,Object>> items=new ArrayList<Map<String,Object>>();
cursor.moveToFirst();
//叫出資料庫的資料
for(int i=0;i< cursor.getCount();i++){
Map<String,Object> item=new HashMap<String,Object>();
item.put("variety",cursor.getString(0));
item.put("old",cursor.getString(1));
item.put("hair",cursor.getString(2));
item.put("where_from",cursor.getString(3));
item.put("flesh",cursor.getString(4));
item.put("sex",cursor.getString(5));
items.add(item);//新增
cursor.moveToNext();//移下一筆資料
}
SimpleAdapter SA=new SimpleAdapter(this,items,R.layout.people_look_for,new String[]{"variety","where_from","sex"},new int[]{R.id.place,R.id.variety_thing,R.id.sex});
LV1.setAdapter(SA);
----> String test = items.toString();
列出的資料會是全部的資料 如果我想指定"variety"這個欄位下的 我該怎麼做
如果你是要用品種篩選資料的話
Cursor cursor=db.query("missing",new String[]{ "variety", "old ", "hair","where_from","flesh", "sex" },null,null,null,null,null);
改成
Cursor cursor=db.query("missing",new String[]{ "variety", "old ", "hair","where_from","flesh", "sex" },"variety=哈士奇",null,null,null,null);
試看看
去想一下你的cursor是在做什麼的,要取得該筆資料你可以透過很多方式,名稱或key id之類的
cursor.get________