title: Gridview get image from JSON using AsyncTask
body: <p>This project I've done with image in my drawable but now I want to get image url from JSON by using Asynctask and display it. and I make php that provide a json string like below.</p>
  
  <p>I want to get path of image(url) by using AsyncTask from JSON.
  I want to use data from json instead of <code>public mThumbId = {...};</code></p>
  
  <pre><code> {"count":"28","data":
      [{"id":"1",
          "first_name":"man",
          "last_name":"woman",
          "username":"man",
          "password":"4f70432e636970de9929bcc6f1b72412",
          "email":"man@gmail.com",
          "url":"http://vulcan.wr.usgs.gov/Imgs/Jpg/MSH/Images/MSH64_aerial_view_st_helens_from_NE_09-64_med.jpg"},
      {"id":"2",
              "first_name":"first",
              "last_name":"Last Name",
              "username":"user",
              "password":"1a1dc91c907325c69271ddf0c944bc72",
              "email":"first@gmail.com",
              "url":"http://www.danheller.com/images/California/Marin/Scenics/bird-view-big.jpg"},
      {"id":"3",
              "first_name":"first",
              "last_name":"Last Name",
              "username":"user",
              "password":"1a1dc91c907325c69271ddf0c944bc72",
              "email":"0",
              "url":"http://www.hermes.net.au/bodhi/images/view/large/view_03.jpg"}]}
  </code></pre>
  
  <p>AndroidGridLayoutActivity</p>
  
  <pre><code>GridView gridView = (GridView) findViewById(R.id.grid_view);        
      gridView.setAdapter(new ImageAdapter(this));
  
      gridView.setOnItemClickListener(new OnItemClickListener() {
          public void onItemClick(AdapterView&lt;?&gt; parent, View v,
                  int position, long id) {
  
              Intent i = new Intent(getApplicationContext(), FullImageActivity.class);
              i.putExtra("id", position);
              startActivity(i);
          }
      });
  </code></pre>
  
  <p>ImageAdapter</p>
  
  <pre><code>public class ImageAdapter extends BaseAdapter {
  private Context mContext;
  
  // Keep all Images in array
  public Integer[] mThumbIds = {
          R.drawable.pic_1, R.drawable.pic_2,
          R.drawable.pic_3, R.drawable.pic_4,
          R.drawable.pic_5, R.drawable.pic_6,
          R.drawable.pic_7, R.drawable.pic_8,
          R.drawable.pic_9, R.drawable.pic_10,
          R.drawable.pic_11, R.drawable.pic_12,
          R.drawable.pic_13, R.drawable.pic_14,
          R.drawable.pic_15
  };
  
  // Constructor
  public ImageAdapter(Context c){
      mContext = c;
  }
  
  public int getCount() {
      return mThumbIds.length;
  }
  
  public Object getItem(int position) {
      return mThumbIds[position];
  }
  
  public long getItemId(int position) {
      return 0;
  }
  
  public View getView(int position, View convertView, ViewGroup parent) {         
      ImageView imageView = new ImageView(mContext);
      imageView.setImageResource(mThumbIds[position]);
      imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
      imageView.setLayoutParams(new GridView.LayoutParams(70, 70));
      return imageView;
  }
  
  }
  </code></pre>
  
  <p>FullImageActivity</p>
  
  <pre><code>Intent i = getIntent();
      int position = i.getExtras().getInt("id");
      ImageAdapter imageAdapter = new ImageAdapter(this);
  
      ImageView imageView = (ImageView) findViewById(R.id.full_image_view);
      imageView.setImageResource(imageAdapter.mThumbIds[position]);
  </code></pre>