title: How to display images coming from webservice in android
body: <p>We are working on a project where data is coming from webservice.I am dispalying that data in listview.The data icludes images as image path.I have displayed all the iformation but i couldt display the image.How to display the images from webservices.</p>
  
  <p>my code is:</p>
  
  <pre><code>package com.example.doctreachapp;
  
  
  
   import java.util.ArrayList;
   import java.util.HashMap;
  
   import org.json.JSONArray;
   import org.json.JSONException;
   import org.json.JSONObject;
  
   import com.example.doctreachapp.JSONParser;
   import com.example.doctreachapp.R;
  
   import android.app.ListActivity;
   import android.app.ProgressDialog;
   import android.content.Context;
   import android.graphics.Bitmap;
   import android.os.AsyncTask;
   import android.os.Bundle;
   import android.util.Log;
   import android.view.LayoutInflater;
   import android.view.View;
   import android.view.ViewGroup;
   import android.webkit.WebView;
   import android.widget.BaseAdapter;
   import android.widget.ImageView;
   import android.widget.ListAdapter;
   import android.widget.ListView;
   import android.widget.SimpleAdapter;
   import android.widget.TextView;
  
  
   public class GeneralHospitals extends ListActivity {
  private Context context;
  private static String url = "my Url";
  // private static final String ID = "ID";
  String TAG_user_detail = "DentalHospitals";
  private static final String Img = "Img";
  private static final String Location = "Location";
  private static final String URL = "URL";
  private static final String Name = "Name";
  private static final String Distance = "Distance";
  
  String imagestack;
   Bitmap image; 
  JSONArray user_detail_jsonarray = null;
  ArrayList&lt;HashMap&lt;String, String&gt;&gt; jsonlist = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
  ListView lv;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main2);
      lv = (ListView) findViewById(android.R.id.list);
      new ProgressTask().execute();
  }
  
  private class ProgressTask extends AsyncTask&lt;String, Void, Boolean&gt; {
  
      @Override
      protected void onPostExecute(final Boolean success) {
  
          setListView();
          // select single ListView item
          // lv = getListView();
      }
  
      protected Boolean doInBackground(final String... args) {
  
          JSONParser jParser = new JSONParser();
          // get JSON data from URL
          // JSONObject jobject = new JSONObject(result);
          JSONObject json = jParser.getJSONFromUrl(url);
          Log.d("json", json.toString());
          try {
              user_detail_jsonarray = json.getJSONArray("DentalHospitals");
              Log.d("jsonarray", user_detail_jsonarray.toString());
          } catch (JSONException e1) {
              // TODO Auto-generated catch block
              e1.printStackTrace();
          }
          for (int i = 0; i &lt; user_detail_jsonarray.length(); i++) {
              try {
                  JSONObject c = user_detail_jsonarray.getJSONObject(i);
                  String img = c.getString(Img);
                  String name = c.getString(Name);
                  String loc = c.getString(Location);
                  String url = c.getString(URL);
                  String dis = c.getString(Distance);
                  HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
                  // Add child node to HashMap key &amp; value
                  map.put(Img, img);
                  map.put(Name, name);
                  map.put(Location, loc);
                  map.put(URL, url);
                  map.put(Distance, dis);
                  jsonlist.add(map);
                  // Log.d("list",jsonlist);
  
              } catch (JSONException e) {
                  e.printStackTrace();
              }
              Log.d("JSONList", jsonlist.toString());
          }
          return true;
      }
  }
  
  public class CustomListAdapter extends BaseAdapter {
  
      private ArrayList&lt;HashMap&lt;String, String&gt;&gt; listData;
  
      private LayoutInflater layoutInflater;
  
      public CustomListAdapter(Context context,
              ArrayList&lt;HashMap&lt;String, String&gt;&gt; jsonlist) {
          this.listData = jsonlist;
          layoutInflater = LayoutInflater.from(context);
      }
  
      @Override
      public int getCount() {
          return listData.size();
      }
  
      @Override
      public Object getItem(int position) {
          return listData.get(position);
      }
  
      @Override
      public long getItemId(int position) {
          return position;
      }
  
      public View getView(int position, View convertView, ViewGroup parent) {
          ViewHolder holder;
          if (convertView == null) {
              convertView = layoutInflater.inflate(R.layout.list_item, null);
              holder = new ViewHolder();
              holder.Name = (TextView) convertView
                      .findViewById(R.id.name);
              holder.Location = (TextView) convertView
                      .findViewById(R.id.loc);
              holder.URL = (TextView) convertView
                      .findViewById(R.id.url);
              holder.Distance = (TextView) convertView
                      .findViewById(R.id.dis);
              holder.Img = (ImageView) convertView
                      .findViewById(R.id.image);
  
              convertView.setTag(holder);
          } else {
              holder = (ViewHolder) convertView.getTag();
          }
            //System.out.println(listData.get(position).get("Img"));
              System.out.println(listData.get(position).get("Name"));
          holder.Img.setImageURI(listData.get(position).get("Img"));
          holder.Name.setText(listData.get(position).get("Name"));
          holder.Location.setText(listData.get(position).get("Location"));
          holder.URL.setText(listData.get(position).get("URL"));
          holder.Distance.setText(listData.get(position).get("Distance"));
          //WebView image = holder.Img;
  
          //imagestack = listData.get(position).get("Img");
          //image = BitmapFactory.decodeStream((listData.get(position).get("Img")).openStream());
          Log.d("image",imagestack);
  
          return convertView;
      }
  
  }
  
  public static class ViewHolder {
      ImageView Img;
      TextView Location;
      TextView Name;
      TextView URL;
      TextView Distance;
  }
  
  public void setListView() {
      // TODO Auto-generated method stub
  
      CustomListAdapter adapter = new CustomListAdapter(this, jsonlist);
      Log.d("ABCD", "" + lv.getVisibility());
      lv.setAdapter(adapter);
  
  }
  
  }
  
  
  
  
      Please help me.     
  </code></pre>