我正在研究一個應用程序,它需要獲得新的標題並在listView中添加拇指圖像,並且我不知道如何將照片url轉換爲圖像並放入listView我在這裏的代碼:用json解析圖像到ListView旁邊的ListView
我可以得到圖像的網址,但我不知道該怎麼做才能添加到我得到的文本旁邊的listView,任何幫助?
private class theJob extends AsyncTask<String, Void, ArrayList<HashMap<String, String>>>{
@Override
protected void onPostExecute(ArrayList<HashMap<String, String>> result) {
ListAdapter adapter = new SimpleAdapter(MainActivity.this, result, R.layout.list_item,
new String[] {TAG_CAT_NAME }, new int[] {R.id.label });
setListAdapter(adapter);
Log.d("adapter", "works");
}
@Override
protected ArrayList<HashMap<String, String>> doInBackground(
String... params) {
// TODO Auto-generated method stub
Log.d("Format", params[0]);
Log.d("URL", params[1]);
ArrayList<HashMap<String, String>> cat = new ArrayList<HashMap<String,String>>();
JsonParser jparser = new JsonParser();
Log.d("url", "to the other class");
JSONArray jArray = jparser.getJSONfronUrl(params[1]);
Log.d("json array", "created");
try{
for(int i=0 ; i< jArray.length() ; i++){
JSONObject joob = jArray.getJSONObject(i);
Log.d("jobj", "done");
String title = joob.getString(params[0]);
Log.d(TAG_CAT_NAME, "done");
cat_id = joob.getString(TAG_CAT_ID);
Log.d(TAG_CAT_ID, cat_id);
cat_url.add(i, joob.getString(TAG_CAT_URL)) ;
HashMap<String, String> map = new HashMap<String, String>();
map.put(params[0], title);
cat.add(map);
}
}catch(JSONException e){
e.printStackTrace();
}
Log.d("Going to ADAPTER", "working");
return cat;
}
}
謝謝..它確實可以工作但開車送我到另一個問題 的imageloader.java沒有影像傳回當我打電話從我的lazyadapter.java(工作延伸的AsyncTask ..)類.. 我不知道爲什麼! – vezikon
實際上沒有幫助..我仍然無法做到這一點 – vezikon