Grid view image source issue
<p>i am trying to send an array containing strings of url of the image source to the imageadapter of the grid view. But only the last url of the array is being used to set the image in the adapter. some help here would be appreciated.</p>

<pre><code>GridView gridview = (GridView) findViewById(R.id.gridview);
    ImageAdapter imageListAdapter = null;
    for( int inx = 0 ; inx &lt; imageUrl.length ; inx++)
        {
                 imageListAdapter = new ImageAdapter(context,imageUrl[inx],productName[inx] );
                 System.out.println(imageUrl[inx]);
                 System.out.println(productName[inx]);
                 gridview.setAdapter(imageListAdapter);
        }
</code></pre>

<p>adapter code :</p>

<pre><code>public class ImageAdapter extends BaseAdapter {
private Context mContext;
static int i = 0;
String url = null;
String name = null;

public ImageAdapter(Context c, String url , String name ) {
    mContext = c;
    this.url = url;
    this.name = name;
}

public int getCount() {
    // return url.length;
    return ++i;
}

public Object getItem(int position) {
    return null;
}

public long getItemId(int position) {
    return 0;
}

// create a new ImageView for each item referenced by the Adapter
public View getView(final int position, View convertView, ViewGroup parent) {
    ImageView imageView;

    if (convertView == null) {  // if it's not recycled, initialise some attributes
        imageView = new ImageView(mContext);
        imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
        imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
        imageView.setPadding(8,8,8,8);
    } else {
        imageView = (ImageView) convertView;
    }
    //imageView.setImageResource(mThumbIds[position]);
    //Bitmap bmp  = loadBitmap("http://www.xvr.com/aero/planes/boeing/boeingf15.jpg");

    Bitmap bmp  = loadBitmap(url);
    System.out.println("in adapter :"+url);
    //imageView.setImageResource(mThumbIds[position]);
    imageView.setImageBitmap(bmp);
    return imageView;
}
public static Bitmap loadBitmap(String url) 
{
    Bitmap bitmap = null;
    InputStream in = null;
    BufferedOutputStream out = null;

    try {
        in = new BufferedInputStream(new URL(url).openStream(),  4 * 1024);

        final ByteArrayOutputStream dataStream = new ByteArrayOutputStream();
        out = new BufferedOutputStream(dataStream,  4 * 1024);

        int byte_;
        while ((byte_ = in.read()) != -1)
            out.write(byte_);
        out.flush();

        final byte[] data = dataStream.toByteArray();
        BitmapFactory.Options options = new BitmapFactory.Options();
        //options.inSampleSize = 1;

        bitmap = BitmapFactory.decodeByteArray(data, 0, data.length,options);
    } catch (IOException e) {
        Log.e("","Could not load Bitmap from: " + url);
    } finally {
        try{
            in.close();
            out.close();
        }catch( IOException e )
        {
            System.out.println(e);
        }
    }
    return bitmap;
}
</code></pre>

<p>}</p>
