Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have a Bitmap array in android, now I need to add this array to an ArrayList. I did this like

ArrayList<Bitmap> bmp_images = new ArrayList<Bitmap>(Arrays.asList(bmp));

But it showing an error The constructor ArrayList(List) is undefined

where bmp is the Bitmap array. What should i do please someone help me to fix this

share|improve this question

closed as unclear what you're asking by laalto, Eric, Noctis Skytower, Elliott Frisch, Daniel Mann Jun 3 at 18:33

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

3  
post bmp declaration... –  Gopal Rao Jun 3 at 6:17
    
Store the bitmap on your device and then add the path to the list. Why do you want bitmap in a list? –  Raghunandan Jun 3 at 6:21
    
@GopalRao sorry its just a mistake about the bitmap array declaration –  Дмитрий Иванович Менделеев Jun 3 at 6:26
    
I figured. The error message is interesting, though. What was the mistake you were making? –  drewmoore Jun 3 at 6:28
    
@drewmore This error is shown if bmp is an array of something other than Bitmap –  Apoorv Jun 3 at 6:38

3 Answers 3

You can add every single item one by one or you can consider using Collections.addAll.

share|improve this answer

Hope this can help you.

ArrayList<Bitmap> bmp_images = new ArrayList<Bitmap>();
for(int i = 0; i < bmp.length ;i++ ){
     bmp_images.add(bmp[i]);
}
share|improve this answer
1  
so whats wrong with ArrayList<Bitmap> bmp_images = new ArrayList<Bitmap>(Arrays.asList(bmp));??? –  Gopal Rao Jun 3 at 6:21
    
-1 Is this really necessary? The code OP posted is good Java. Is there a concrete reason it can't work on Android? If so, that should be part of your answer. If not, I would never recommend using a loop where there is a library function available, and neither should you. –  drewmoore Jun 3 at 6:21
    
@GopalRaonothing wrong with it thankyou –  Дмитрий Иванович Менделеев Jun 3 at 6:27

You can simply use (assuming bmp is Bitmap[])

List<Bitmap> bmp_images = Arrays.asList(bmp);

And there is no need for creating a copy of this collection (depending on your needs)

But it seems you have some problems with declarations of bmp array, so inspect that part.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.