我正在做一个项目。那可以通过json填充列表。我已经解析了来自http://10.0.2.2/mobile_version/get_supplier_pro_list.php的数据,它显示的是文本而不是图像,我所做的是
// 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}
需要帮助。提前致谢。