开发者

ListView with photos from Gallery

开发者 https://www.devze.com 2023-01-25 14:20 出处:网络
I have a listview that has a photograph from the gallery for each entry but it was blowing up and running out of memory so I resized the image

I have a listview that has a photograph from the gallery for each entry but it was blowing up and running out of memory so I resized the image

开发者_StackOverflow中文版BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inSampleSize = 8; 
Bitmap yourSelectedImage = BitmapFactory.decodeFile(photo,opts);
imgView.setImageBitmap(yourSelectedImage);

The problem I have is that each image in the list has to be resized before it is displaying the view.

Is there a way to link to the thumbnail view instead of the full size image so that I don't have to resize them or is there a way to load each picture as it is sized instead of having to wait for them all.


This basically sounds like exactly the sort of thing you want from droid-fu's remote image handling, only simpler (the "remote loading" part is really just scaling an image loaded from the Gallery instead of downloading one from the Web). You should be able to use very similar code. Alternatively, this is pretty close to this SO question about lazy-loading images.

0

精彩评论

暂无评论...
验证码 换一张
取 消