Display gallery remote image in android imageView
<p>I am using image view and gallery in my xml file. i am getting gallery image for webservice(remote images).</p>

<p>when i select image from gallery i want to display in android image view. </p>

<p>here my code,</p>

<pre><code> ImageAdapter.java

public class ImageAdapter extends BaseAdapter
{
    private Context context = null;
     DataService Ds;
    LayoutInflater mInflater;

     private String[] myRemoteImages;



    public ImageAdapter(Context context)
        {
            this.context = context;
            //myRemoteImages = imgArray;
            mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        }

    @Override
    public int getCount()
        {
            return this.myRemoteImages.length;
        }

    @Override
    public final Object getItem(int position)
        {
            return position;
        }

    @Override
    public long getItemId(int position)
        {
            return position;
        }

    @Override
    public View getView(int position, View view, ViewGroup group)
        {
            ImageView imageView = new ImageView(this.context);          

             try {

                 URL aURL = new URL(myRemoteImages[position]);
                 System.err.println(aURL);
                 URLConnection conn = aURL.openConnection();
                 conn.connect();
                 InputStream is = conn.getInputStream();
                 BufferedInputStream bis = new BufferedInputStream(is);
                 Bitmap bm = BitmapFactory.decodeStream(bis);
                 bis.close();
                 is.close();

                 imageView.setImageBitmap(bm);

            } catch (IOException e) {
                //imageView.setImageResource(R.drawable.nopic);
                 Log.e("DEBUGTAG", "Remote Image Exception", e);
            }
            imageView.setImageResource(position);
            imageView.setLayoutParams(new Gallery.LayoutParams(105, 70));
            return imageView;
        }

    public String[] getMyRemoteImages() {
        return myRemoteImages;
    }

    public void setMyRemoteImages(String[] myRemoteImages) {
        this.myRemoteImages = myRemoteImages;
    }
}


and DisplayImage.java

ImageView imgView;

gallery = (Gallery) this.findViewById(R.id.Gallery01);
        imageAdapter = new ImageAdapter(this);
        imageAdapter.setMyRemoteImages(ItemList.getImages());
        gallery.setAdapter(imageAdapter);

        gallery.setOnItemClickListener(new OnItemClickListener() 
        {
            public void onItemClick(AdapterView parent, 
            View v, int position, long id) 
            {          
                System.out.println("gallery position" +imageAdapter.getItemViewType(position));
                imgView.setImageResource(imageAdapter.getItemViewType(position));


            }
        });  
        }
</code></pre>

<p>any one can help me?</p>

<p>thanks in advance</p>
