0
我正在開發一個項目。這可以通過json填充列表。我從http://10.0.2.2/mobile_version/get_supplier_pro_list.php分析數據,並且它顯示我的文字而不是圖像,我做了什麼是從本地主機解析JSON圖像
// Hashmap for ListView
ArrayList<HashMap<String, String>> contactList = new ArrayList<HashMap<String, String>>();
// Creating JSON Parser instance
JSONParser jParser = new JSONParser();
// getting JSON string from URL
JSONObject json = jParser.getJSONFromUrl(url);
try {
// Getting Array of Contacts
sup_pd_list = json.getJSONArray(TAG_SUPPLIERS);
// looping through All Contacts
for (int i = 0; i < sup_pd_list.length(); i++) {
JSONObject c = sup_pd_list.getJSONObject(i);
// Storing each json item in variable
String suply_id = c.getString(TAG_ID);
String pd_name = c.getString(TAG_PRO_NAME);
String pd_price = c.getString(TAG_PRO_PRICE);
String pd_thumbnail = c.getString(TAG_PRO_THUMBNAIL);
// creating new HashMap
HashMap<String, String> map = new HashMap<String, String>();
// adding each child node to HashMap key => value
map.put(TAG_ID, suply_id);
map.put(TAG_PRO_NAME, pd_name);
map.put(TAG_PRO_PRICE, pd_price);
map.put(TAG_PRO_THUMBNAIL, pd_thumbnail);
// adding HashList to ArrayList
contactList.add(map);
}
} catch (JSONException e) {
e.printStackTrace();
}
/**
* Updating parsed JSON data into ListView
* */
ListAdapter adapter = new SimpleAdapter(this, contactList,
R.layout.single_list_item, new String[] { TAG_PRO_NAME,
TAG_PRO_PRICE, TAG_PRO_THUMBNAIL}, new int[] {
R.id.pd_name, R.id.pd_price , R.id.pd_thumbnail });
setListAdapter(adapter);
}
和logcat的,它讓我
12-14 03:47:12.743: I/System.out(314): resolveUri failed on bad bitmap uri: fceacd5431438f9d93fb4f885a3b2990.png
12-14 03:47:12.762: I/System.out(314): resolveUri failed on bad bitmap uri: d254d82762217f8e1005013c8926f53e.jpg
並通過分析,我所得到的是需要
{"suppliers":[{"suply_id":null,"pd_name":"car","pd_price":"200000.00","pd_thumbnail":"fceacd5431438f9d93fb4f885a3b2990.png"}],"success":1}
幫助。提前致謝。
設備上或遠程服務器上的圖像(在本例中是您的PHP本地站點)? – AngeloS
在數據庫中,mysql。 – Numair
圖像名稱是在MySQL中或圖像在MySQL中以字節存儲?因爲你的JSON字符串具有看起來像文件'fceacd5431438f9d93fb4f885a3b2990.png'的名稱。如果該文件不在android設備上,則需要具有該映像的完整URL – AngeloS