user3739970
user3739970

Reputation: 591

How to Store Images from URL in Array

i want to store Images in array from URL but i don't know how to implement this functionality.

just like i stored images from drawable in array i want to store images in array from URL.

example of drawable:

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
    };

i tried this but it didn't work:

public Integer[] mThumbIds = {
            R.string.http_icons_iconarchive_com_icons_martz90_circle_512_android_icon_png

    };

Upvotes: 0

Views: 5306

Answers (4)

rupesh jain
rupesh jain

Reputation: 3430

Do something like this:

ArrayList<Bitmap> imagesList= new ArrayList<Bitmap>();
//loop and download image and put it in this list
imagesList.add(bitmap);

Upvotes: 0

Shaharyar Keerio
Shaharyar Keerio

Reputation: 17

simply first download Lib from http://square.github.io/picasso/

then Picasso.with(context).load("your url of img").into(imageView);

Upvotes: 1

SaravanaRaja
SaravanaRaja

Reputation: 3406

I'm new to android,through some net surfing i came up to this answer. Make a bitmap array to get the image from url and then use it where ever you need, got the idea from this link [Load image from url

Bitmap[] mThumbIds =new Bitmap[10];//for exapmle 10
URL url = new URL("Your URL");//image url is stored here
mThumbIds[0]= BitmapFactory.decodeStream(url.openConnection().getInputStream());//this line help to get the image(for given url) and store it in BitMapArray

usage of above array to display it in imageview

imageView.setImageBitmap(mThumbIds[0]);

Upvotes: 0

someguy234
someguy234

Reputation: 559

You just need to store the url of the image.

ArrayList<String> imagesFromURL = new ArrayList<String>();
//then do a loop over you urls and
imagesFromURL.add("some url here");

Upvotes: 0

Related Questions