protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Main); //create a new dialog dialog = CustomProgressDialog.CreateDialog(this); dialog.OnWindowFocusChanged(true); Button btnGO = FindViewById<Button>(Resource.Id.go); btnGO.Click += (s,e) => { int result = 0; //show the dialog dialog.Show(); //do some things Task task = new Task(() => { for (int i = 0; i < 100; i++) { result += i; } }); task.ContinueWith(t => { Intent intent = new Intent(this, typeof(LastActivity)); intent.PutExtra("name", result.ToString()); StartActivity(intent); }); task.Start(); }; }
/// <summary> /// create the dialog /// </summary> /// <param name="context">the context</param> /// <returns>the instance of the customize dialog</returns> public static CustomProgressDialog CreateDialog(Context context) { customProgressDialog = new CustomProgressDialog(context, Resource.Style.CustomProgressDialog); //set the view customProgressDialog.SetContentView(Resource.Layout.loading); //set the gravity customProgressDialog.Window.Attributes.Gravity = GravityFlags.Center; return customProgressDialog; }
/// <summary> /// create the dialog /// </summary> /// <param name="context">the context</param> /// <returns>the instance of the customize dialog</returns> public static CustomProgressDialog CreateDialog(Context context) { customProgressDialog = new CustomProgressDialog(context, Resource.Style.CustomProgressDialog); //set the view customProgressDialog.SetContentView(Resource.Layout.loading); //set the gravity customProgressDialog.Window.Attributes.Gravity = GravityFlags.Center; return(customProgressDialog); }