I’m working on an app which require to get the new titles and add thumb images beside them in listView and I don’t know how to convet the photos url to images and put in the listView I made here’s the code :
I can get the image url but I don’t know what to do to add to the listView beside the text I got, any help ?
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;
}
}
Here is a googe example this will help you what you want 🙂
Update
Here you will fine more help about Lazy loading of images in list view.