Reputation: 30068
In android volley
, I know there's an attribute called mDefaultImageId
in the NetwrokImageView. But this only displays "Default" still images.
I need to show either an animated image or a progress bar.
I know I can accomplish this if I use RequestQueue
, but still I need to take advantages of ImageLoader
.
How to accomplish that?
Thanks.
Upvotes: 2
Views: 3706
Reputation: 41
if you are using method to load image then ProgressBar as parameter to that method may help you to hide ProgressBar:
https://stackoverflow.com/a/32666637/5045178
Upvotes: 1
Reputation: 5540
You can try this: https://github.com/vinaysshenoy/enhanced-volley there is Animation added to Volley.
also you can use
NetworkImageView ivImage = (NetworkImageView) rootView.findViewById(R.id.ivImage);
ivImage.setImageUrl(key, mImageLoader);
ivImage.setDefaultImageResId(R.drawable.loading_text);
where for me drawable loading_text was image saying "Loading image..."
Upvotes: 1
Reputation: 8680
You can create your own implementation of the ImageListener
class and pass it when requesting the image.
Something along the lines of:
// code for displaying animation / progress wheel
sImageLoader.get(imageUrl, new ImageListener() {
@Override
public void onErrorResponse(VolleyError error) {
// handle errors
}
@Override
public void onResponse(ImageContainer response, boolean isImmediate) {
if (response.getBitmap() != null) {
// code to switch out placeholder animation
// progress wheel with received response
}
}
});
Upvotes: 3