nostra13 / Android-Universal-Image-Loader

Powerful and flexible library for loading, caching and displaying images on Android.
Apache License 2.0
16.78k stars 6.1k forks source link

how to re-set icons for menu items, after screen rotatation #999

Open yongsunCN opened 9 years ago

yongsunCN commented 9 years ago

My aim is to download an image from web then set it as the icon for a menu item. Right now I'm using code below in onOptionCreateOptionsMenu()

loader.loadImage(url, new SimpleImageLoadingListener() {
                            @Override
                            public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
                                if(theItem != null) {
                                    theItem.setIcon(new BitmapDrawable(getResources(), loadedImage));
                                }
                            }
                        });

However, the onLoadingComplete only runs on the first time. If I rotate the screen the icon won't be set again. How do I solve this problem?

Thanks.

StefanoGR commented 9 years ago

This is not an issue with the image loader. Catch the rotation event and reload the picture if needed.

yongsunCN commented 9 years ago

How do I reload the picture? the second time the loader won't download the picture again because of the same url of the picture. So onLoadingComplete won't be called. Or is there any other approach I'm not aware of?