데이터베이스에서 내 안드로이드 응용 프로그램으로 이미지를로드하고이를 listview에 저장하려면 어떻게해야합니까? 데이터베이스는 MySQL이고 이미지는 png 형식으로 저장됩니다.어떻게 이미지를 android에로드합니까?
다음은 데이터베이스에서 데이터를 검색하기위한 코드입니다. a_emblem는 이미지 뷰 내 JSON에있는 이미지
여기private void showResult() {
JSONObject jsonObject;
ArrayList<HashMap<String, String>> list = new ArrayList<>();
try {
jsonObject = new JSONObject(JSON_STRING);
JSONArray result = jsonObject.getJSONArray(Config.TAG_JSON_ARRAY1);
for (int i = 0; i < result.length(); i++) {
JSONObject jo = result.getJSONObject(i);
String a_shortcut = jo.getString(Config.TAG_a_shortcut);
String a_emblem = jo.getString(Config.TAG_a_emblem);
String gold = jo.getString(Config.TAG_gold);
String silver = jo.getString(Config.TAG_silver);
String bronze = jo.getString(Config.TAG_bronze);
String total = jo.getString(Config.TAG_total);
HashMap<String, String> match = new HashMap<>();
match.put(Config.TAG_a_shortcut, a_shortcut);
match.put(Config.TAG_a_emblem, a_emblem);
match.put(Config.TAG_gold, gold);
match.put(Config.TAG_silver, silver);
match.put(Config.TAG_bronze, bronze);
match.put(Config.TAG_total, total);
list.add(match);
}
} catch (JSONException e) {
e.printStackTrace();
}
ListAdapter adapter = new SimpleAdapter(
getActivity(), list, R.layout.standlayout,
new String[]{Config.TAG_a_shortcut, Config.TAG_a_emblem, Config.TAG_gold, Config.TAG_silver, Config.TAG_bronze, Config.TAG_total},
new int[]{R.id.shortcut, R.id.img, R.id.gold, R.id.silver, R.id.bronze, R.id.total});
lv.setAdapter(adapter);
}
더 많은 문맥없이 대답 할 수 없습니다. 이 이미지는 어떻게 데이터베이스에 저장됩니까? 데이터베이스가 어쨌든 무엇입니까? –
이렇게하려면 사용자 지정 어댑터 클래스를 사용해야합니다. – sam
@ KenY-N 데이터베이스를 추가하고 이미지 저장 방법 – orange