Hello everybody,
I need to show a loader/spinner in place of my ImageView
until the image gets downloaded. Currently, there is only a blank space shown and the image is displayed once totally downloaded. This is what I currently have:
private void DisplayQrCode(String uriString)
{
WebClient web = new WebClient ();
web.DownloadDataCompleted += new DownloadDataCompletedEventHandler(web_DownloadDataCompleted);
web.DownloadDataAsync (new Uri(uriString));
}
void web_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
{
if (e.Error != null)
{
RunOnUiThread(() =>
Toast.MakeText(this, e.Error.Message, ToastLength.Short).Show());
}
else
{
Bitmap bm = BitmapFactory.DecodeByteArray(e.Result, 0, e.Result.Length);
RunOnUiThread(() =>
{
ImageView imgQrCode = FindViewById<ImageView>(Resource.Id.imgQrCode);
imgQrCode.SetImageBitmap(bm);
});
}
}