Reputation: 48602
How can I add the Progress dialog
in ImageView
until I loading image from server in android. When image download complete then display the image.
try {
cachedImage = imageLoader.loadImage(mTopicList.getTopicImage(j),
new ImageLoadedListener() {
public void imageLoaded(Bitmap imageBitmap)
{
imageView.setImageBitmap(imageBitmap);
imageView.invalidate();
}
});
} catch (Exception e) {
e.printStackTrace();
}
Upvotes: 4
Views: 2579
Reputation: 48602
Approach which I followed to do this. Use the Frame Layout and have a ImageView
and ProgressBar
inside it. I've used the Universal Image Loader Library, which have callback once image has been downloaded. Initially show the ProgressBar
and hide the ImageView
to invisible. Once image has been downloaded then hide the ProgressBar
and show the image in the ImageView
.
Initially
imageView.setVisibility(View.INVISIBLE);
progressBar.setVisibility(View.VISIBLE);
Load your image now. After loading it, call this:
progressBar.setVisibility(View.INVISIBLE);
imageView.setVisibility(View.VISIBLE);
Hope this help to you all!
Upvotes: 2