I have an actionbar in which I am showing weather. In the postexecute
method of the async
, I want to set the image of the weather from a url. By default, the displayImage
of the UIL
takes uri
and imageWare
in which to display the image.
This is how I am doing it:
ImageLoader.getInstance().displayImage(url, (ImageAware) MainActivity.btnWeather.getIcon());
Where btnWeather
is a menuItem
in the actionbar. I cannot get this to work.. How should I setIcon
using the UIL..
In my project I am using the ImageLoadingListener callback to set the icon resource:
ImageLoader.getInstance().loadImage(url, new ImageLoadingListener() {
@Override
public void onLoadingStarted(String imageUri, View view) {
}
@Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
}
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
MainActivity.btnWeather.setIcon(new BitmapDrawable(loadedImage));
}
@Override
public void onLoadingCancelled(String imageUri, View view) {
}
});
Also, you can display custom images when the load starts, fails or is cancelled.