private void display_bundle() {
SQLiteDatabase db=DH.getWritableDatabase();
ContentValues values=new ContentValues();
ListView LV1=(ListView)findViewById(R.id.seeto);//讀取元件
// 查詢資料庫並載入
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);
//
goLookfor_people = new ArrayList<>();
goLookfor_people.add(new Lookfor_people("??","??","??","?" ));
goLookfor_people.add(new Lookfor_people("高雄市","女","人類",R.drawable.dodo));
goLookfor_people.add(new Lookfor_people("台南市","男","土狗",R.drawable.dodo));
goLookfor_people.add(new Lookfor_people("高雄市","女","貴濱",R.drawable.dodo));
goLookfor_people.add(new Lookfor_people("台東市","女","哈士奇",R.drawable.dog_1));
goLookfor_people.add(new Lookfor_people("澎湖市","女","黃金",R.drawable.dog_2));
goLookfor_people.add(new Lookfor_people("厚德市","女","娓娓",R.drawable.dog_3));
RecyclerView myra =findViewById(R.id.recycle_id_people);
RecyclerViewAdapter_lookfor_people myAdapter =new RecyclerViewAdapter_lookfor_people(this,goLookfor_people);
myra.setLayoutManager(new GridLayoutManager(this,3));
myra.setAdapter(myAdapter);
}
```!
![https://ithelp.ithome.com.tw/upload/images/20181204/201096856gi8WaymWF.png](https://ithelp.ithome.com.tw/upload/images/20181204/201096856gi8WaymWF.png)
如goLookfor_people.add(new Lookfor_people("??","??","??","?" )); 我想使用資料庫裡的資料 不是假資料 我該怎麼打
你都會用上傳圖片的功能了
建議你使用左邊兩格的「程式碼」功能(紅色框框)
把程式碼貼上來
可能會有更多人回答你的問題
用你的程式改寫成下段
拿去改
看能不能適用
Cursor cursor=db.query("lookforpeople",new String[]{ "city", "gender", "variety"},null,null,null,null,null);
ArrayList goLookfor_people = new ArrayList<>();
cursor.moveToFirst();
//叫出資料庫的資料
for(int i=0;i< cursor.getCount();i++){
goLookfor_people.add(new Lookfor_people(cursor.getString(0),cursor.getString(1),cursor.getString(2),R.drawable.dodo));//新增
cursor.moveToNext();//移下一筆資料
}