1
我正在嘗試使用base64圖像做listview。 Listviews數據是來自服務器的json-array,並創建爲hashmap。Android Studio base64圖像到ListView
JSONObject c = products.getJSONObject(i);
// Storing each json item in variable
String id = c.getString("pid");
String createdAt = c.getString("created_at");
String description = c.getString("description");
String image = c.getString("image");
// creating new HashMap
HashMap<String, String> map = new HashMap<String, String>();
// adding each child node to HashMap key => value
map.put("pid", id);
map.put("description", description);
map.put("image", image);
// adding HashList to ArrayList
productsList.add(map);
}
和:
protected void onPostExecute(String file_url) {
// updating UI from Background Thread
runOnUiThread(new Runnable() {
public void run() {
/*Updating parsed JSON data into ListView*/
ListAdapter adapter = new SimpleAdapter(
listActivity.this, productsList,
R.layout.list_item, new String[] { "product_id",
"product_description", "product_image" },
new int[] { R.id.pid, R.id.description, R.id.image });
// updating listview
setListAdapter(adapter);
}
});
}
我怎樣才能讓轉換爲imageview的這種形象字符串? 我是新的Android Studio,所以我不知道這是否聰明的方式做到這一點..
上面的代碼是從:http://www.androidhive.info/2012/05/how-to-connect-android-with-php-mysql/ 如果有幫助。
如何與ListView的工作?這對一個圖像很好,但我無法創建ListViews圖像。 – Vmaatta