title: how to add imageview in listview in Android
body: <p>i want display image from json url in listview.<br> here is my code:<br>
  <br>activity_main.xml<br>
  </p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:paddingBottom="@dimen/activity_vertical_margin"
      android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:paddingTop="@dimen/activity_vertical_margin"
      tools:context=".MainActivity" &gt;
  
      &lt;ListView
          android:id="@+id/list"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_above="@+id/getdata" /&gt;
  
      &lt;Button
          android:id="@+id/getdata"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentBottom="true"
          android:layout_centerHorizontal="true"
          android:layout_marginBottom="23dp"
          android:text="Get Data" /&gt;
  
  &lt;/RelativeLayout&gt;&lt;br&gt;
  </code></pre>
  
  <p><br>list_v.xml<br></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical" &gt;
  
      &lt;TextView
          android:id="@+id/feed"
          android:layout_width="match_parent"
          android:layout_height="wrap_content" /&gt;
  
      &lt;TextView
          android:id="@+id/tags"
          android:layout_width="match_parent"
          android:layout_height="wrap_content" /&gt;
  
      &lt;ImageView
          android:id="@+id/img"
          android:layout_width="match_parent"
          android:layout_height="wrap_content" /&gt;
  
  &lt;/LinearLayout&gt;&lt;br&gt;
  </code></pre>
  
  <p><br>MainActivity.java<br></p>
  
  <pre><code>package learn2crack.listview;
  
  import java.util.ArrayList;
  import java.util.HashMap;
  import org.json.JSONArray;
  import org.json.JSONException;
  import org.json.JSONObject;
  import android.app.Activity;
  import android.os.AsyncTask;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.AdapterView;
  import android.widget.Button;
  import android.widget.ImageView;
  import android.widget.ListAdapter;
  import android.widget.ListView;
  import android.widget.SimpleAdapter;
  import android.widget.TextView;
  import android.widget.Toast;
  
  import learn2crack.listview.library.JSONParser;
  
  public class MainActivity extends Activity {
      ListView list;
      TextView feed_id;
      TextView tags;
      ImageView thumbnail;
      Button Btngetdata;
      ArrayList&lt;HashMap&lt;String, String&gt;&gt; snowlist = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
      // URL to get JSON Array
      private static String url = "http://instaapi.social-fair.com.208-91-199-15.md-plesk-web1.webhostbox.net/api.php?type=tag&amp;tag=snow";
  
      // JSON Node Names
      private static final String TAG_main = "main";
      private static final String TAG_feed = "feed_id";
      private static final String TAG_tags = "tags";
      private static final String TAG_thumb = "thumbnail";
  
      JSONArray android = null;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          setContentView(R.layout.activity_main);
          snowlist = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
  
          Btngetdata = (Button) findViewById(R.id.getdata);
          Btngetdata.setOnClickListener(new View.OnClickListener() {
  
              @Override
              public void onClick(View view) {
                  new JSONParse().execute();
              }
          });
      }
  
      private class JSONParse extends AsyncTask&lt;String, String, JSONObject&gt; {
  
          @Override
          protected void onPreExecute() {
              super.onPreExecute();
              feed_id = (TextView) findViewById(R.id.feed);
              tags = (TextView) findViewById(R.id.tags);
              thumbnail = (ImageView) findViewById(R.id.img);
          }
  
          @Override
          protected JSONObject doInBackground(String... args) {
  
              JSONParser jParser = new JSONParser();
  
              // Getting JSON from URL
              JSONObject json = jParser.getJSONFromUrl(url);
              return json;
          }
  
          @Override
          protected void onPostExecute(JSONObject json) {
  
              try {
                  // Getting JSON Array from URL
                  android = json.getJSONArray(TAG_main);
                  for (int i = 0; i &lt; android.length(); i++) {
                      JSONObject c = android.getJSONObject(i);
  
                      // Storing JSON item in a Variable
                      String feed = c.getString(TAG_feed);
                      String tags = c.getString(TAG_tags);
                      String thumb = c.getString(TAG_thumb);
  
                      // Adding value HashMap key =&gt; value
                      HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
  
                      map.put(TAG_feed, feed);
                      map.put(TAG_tags, tags);
                      map.put(TAG_thumb, thumb);
  
                      snowlist.add(map);
                      list = (ListView) findViewById(R.id.list);
  
                      ListAdapter adapter = new SimpleAdapter(MainActivity.this,
                              snowlist, R.layout.list_v, new String[] { TAG_feed,
                                      TAG_tags, TAG_thumb }, new int[] {
                                      R.id.feed, R.id.tags, R.id.img });
                      list.setAdapter(adapter);
                      list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
  
                          @Override
                          public void onItemClick(AdapterView&lt;?&gt; parent,
                                  View view, int position, long id) {
                              Toast.makeText(
                                      MainActivity.this,
                                      "You Clicked at "
                                              + snowlist.get(+position).get(
                                                      "tags"), Toast.LENGTH_SHORT)
                                      .show();
  
                          }
                      });
  
                  }
              } catch (JSONException e) {
                  e.printStackTrace();
              }
  
          }
      }
  
  }
  </code></pre>
  
  <p><br>
  <br>JSonParser.java<br></p>
  
  <pre><code>package learn2crack.listview.library;
  
  import java.io.BufferedReader;
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.InputStreamReader;
  import java.io.UnsupportedEncodingException;
  
  import org.apache.http.HttpEntity;
  import org.apache.http.HttpResponse;
  import org.apache.http.client.ClientProtocolException;
  import org.apache.http.client.methods.HttpPost;
  import org.apache.http.impl.client.DefaultHttpClient;
  import org.json.JSONException;
  import org.json.JSONObject;
  
  import android.util.Log;
  
  public class JSONParser {
  
      static InputStream is = null;
      static JSONObject jObj = null;
      static String json = "";
  
      // constructor
      public JSONParser() {
  
      }
  
      public JSONObject getJSONFromUrl(String url) {
  
          // Making HTTP request
          try {
              // defaultHttpClient
              DefaultHttpClient httpClient = new DefaultHttpClient();
              HttpPost httpPost = new HttpPost(url);
  
              HttpResponse httpResponse = httpClient.execute(httpPost);
              HttpEntity httpEntity = httpResponse.getEntity();
              is = httpEntity.getContent();           
  
          } catch (UnsupportedEncodingException e) {
              e.printStackTrace();
          } catch (ClientProtocolException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          }
  
          try {
              BufferedReader reader = new BufferedReader(new InputStreamReader(
                      is, "iso-8859-1"), 8);
              StringBuilder sb = new StringBuilder();
              String line = null;
              while ((line = reader.readLine()) != null) {
                  sb.append(line + "\n");
              }
              is.close();
              json = sb.toString();
          } catch (Exception e) {
              Log.e("Buffer Error", "Error converting result " + e.toString());
          }
  
          // try parse the string to a JSON object
          try {
              jObj = new JSONObject(json);
          } catch (JSONException e) {
              Log.e("JSON Parser", "Error parsing data " + e.toString());
          }
  
          // return JSON String
          return jObj;
  
      }
  }
  </code></pre>
  
  <p><br>
  <br>it display text from json url but not display image<br>
  please help me how can i display image in listview?<br>
  Thank you...</p>