开发者

Lazy List with images and progress display

开发者 https://www.devze.com 2023-01-18 00:30 出处:网络
I have found this example Lazy load of images in ListViewfrom Fedor which is absolutely great for what I need.

I have found this example Lazy load of images in ListView from Fedor which is absolutely great for what I need.

I have a question. if beside the Clear Cache button there would be a TextView how could I put in there how many images from total images had downloaded ? If I know that I will download a tota开发者_JS百科l of 20 images, the status as one image after another will download would be 1/20. 2/20... 20/20.


You would need a variable that contains the number of downloaded images, and each time an image is downloaded you update the variable, and then set that as text on the text view.

You want to be looking at this code inside ImageLoader.java

if(((String)photoToLoad.imageView.getTag()).equals(photoToLoad.url)){
                            BitmapDisplayer bd=new BitmapDisplayer(bmp, photoToLoad.imageView);
                            Activity a=(Activity)photoToLoad.imageView.getContext();
                            a.runOnUiThread(bd);
                        }

Which is executed each time an image is downloaded. In there you could update the variable that you have added and call a method on the ui thread to update the text view.

0

精彩评论

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