In my program i am using local images, but now i want to use online images instead of Drawable
But i don't know what are the changes i have to implement in my code, to get my target done for me.
here is my code, which i am using for drawable images, see:
public int[] IMAGE_IDS = {
R.drawable.flower_01, R.drawable.flower_02,
R.drawable.flower_01, R.drawable.flower_02,
R.drawable.flower_01, R.drawable.flower_02,
R.drawable.flower_01, R.drawable.flower_02
};
And Adapter class, complete code looks like this:
public class AddImageAdapter extends BaseAdapter
{
Context mycontext = null;
int galitembg = 0;
public int[] IMAGE_IDS = {
R.drawable.flower_01, R.drawable.flower_02,
R.drawable.flower_01, R.drawable.flower_02,
R.drawable.flower_01, R.drawable.flower_02,
R.drawable.flower_01, R.drawable.flower_02
};
public AddImageAdapter(Context c)
{
mycontext = c;
TypedArray typArray = mycontext.obtainStyledAttributes(R.styleable.GalleryTheme);
galitembg = typArray.getResourceId(R.styleable.GalleryTheme_android_galleryItemBackground, 0);
typArray.recycle();
}
@Override
public int getCount()
{
return IMAGE_IDS.length;
}
@Override
public Object getItem(int position)
{
return position;
}
@Override
public long getItemId(int position)
{
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
ImageView imageview = new ImageView(mycontext);
imageview.setImageResource(IMAGE_IDS[position]);
imageview.setScaleType(ImageView.ScaleType.FIT_XY);
return imageview;
}
}
I wanna use these two live images URLs in place of drawable
URL-1:
http://files.vividscreen.com/soft/4f9891a78a355e9c4d15fc469eb98625/Sunflowers-480x800.jpg
URL-2:
http://www.hdiphonewallpapers.us/phone-wallpapers/freewallpaper/12960425OV940-3Q61.jpg