ProgressDialog in OnDraw

nkuznetsovnkuznetsov USMember
edited August 2014 in Xamarin.Android

Hi everyone.

Somewhere within my layout I have a custom control, which is essentially a container for a bunch of graphics to happen inside of it. In it's OnDraw method it does a lot of drawing, that takes ~4-5s. What happens is when activity loads, the control starts doing its work, there is no indication to the user that work is being done (i. e. graphics is being drawn). So after that 4-5s delay the graphics appears on the screen all of a sudden, which isn't very user-friendly.

Is it possible to display a progress dialog indicator while the drawing occurs (Android.App.ProgressDialog)? Like so:

protected override void OnDraw(Canvas c)
{
        ShowProgressDialog();

        // lots of drawing

        HideProgressDialog();
}

I tried the above, which yields no effect at all (tried RunOnUiThread(delegate() { }); also).

The control class has access to the parent context (Activity). Activity itself uses progress dialogs for its own operations but when I try to access them from my control, like so -

parent.ShowProgressDialog();

they don't show up.

Thanks.

Posts

  • RaphaelSchindlerRaphaelSchindler USMember ✭✭✭

    Try this ((YourParentActivity)Activity).ShowProgressDialog() where the ShowProgressDialog() must be public.

Sign In or Register to comment.