0

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

    };
2
  • Does not work means what? what did you expected, and what is happening? Commented Aug 7, 2014 at 19:05
  • The best way tis to store all the required image urls in an array and load it in the imageview or wherever you need using Glide/Picassso Commented Nov 16, 2017 at 7:12

4 Answers 4

1

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

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

Sign up to request clarification or add additional context in comments.

Comments

0

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");

Comments

0

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]);

Comments

0

Do something like this:

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.