protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Main); Button start = FindViewById<Button>(Resource.Id.startButton); Button stop = FindViewById<Button>(Resource.Id.stopButton); ProgressDialog pd = new ProgressDialog(this) { Indeterminate = true, }; pd.SetMessage("Waiting"); pd.SetButton("cancel", (s, e) => Stop(pd)); pd.SetIcon(Resource.Drawable.Icon); //pd.SetCancelable(false); Drawable myIcon = Resources.GetDrawable(Resource.Animation.progress_dialog_icon_drawable_animation); pd.SetIndeterminateDrawable(myIcon); start.Click += delegate { Start(pd); }; stop.Click += delegate { Stop(pd); }; }
public void OnItemTap(object sender, AdapterView.ItemClickEventArgs args) { if(progressDialog == null) { progressDialog = new ProgressDialog(this); progressDialog.SetMessage("Uploading your content. Please wait."); progressDialog.SetButton("Cancel Upload", (arg1, arg2) => { if (cancelTokenSource != null) cancelTokenSource.Cancel(); }); progressDialog.Indeterminate = true; } Android.Support.V7.App.AlertDialog alert = new Android.Support.V7.App.AlertDialog.Builder(this) .SetTitle("Scenario Complete!") .SetMessage("What would you like to do with the results of this scenario?") .SetCancelable(true) .SetNegativeButton("Delete", (EventHandler<DialogClickEventArgs>)null) .SetPositiveButton("Upload", (s, a) => { IResultItem toUpload = AppData.Session.ResultsToUpload[args.Position - 1]; progressDialog.Show(); cancelTokenSource = new CancellationTokenSource(); ServerData.PushResult(toUpload, RefreshList, OnUploadComplete, cancelTokenSource.Token); }) .SetNeutralButton("Cancel", (s, a) => { }) .Create(); alert.Show(); // A second alert dialogue, confirming the decision to delete Button negative = alert.GetButton((int)DialogButtonType.Negative); negative.Click += delegate(object s, EventArgs e) { Android.Support.V7.App.AlertDialog.Builder confirm = new Android.Support.V7.App.AlertDialog.Builder(this); confirm.SetTitle("Are you sure?"); confirm.SetMessage("The recorded data will be irrecoverably lost."); confirm.SetPositiveButton("Delete", (senderAlert, confArgs) => { AppData.Session.DeleteResult(AppData.Session.ResultsToUpload[args.Position - 1]); RefreshList(); alert.Dismiss(); }); confirm.SetNegativeButton("Cancel", (senderAlert, confArgs) => { }); confirm.Show(); }; }
protected override Dialog OnCreateDialog(int id) { switch (id) { case DIALOG_YES_NO_MESSAGE: { var builder = new AlertDialog.Builder (this); builder.SetIconAttribute (Android.Resource.Attribute.AlertDialogIcon); builder.SetTitle (Resource.String.alert_dialog_two_buttons_title); builder.SetPositiveButton (Resource.String.alert_dialog_ok, OkClicked); builder.SetNegativeButton (Resource.String.alert_dialog_cancel, CancelClicked); return builder.Create (); } case DIALOG_YES_NO_OLD_SCHOOL_MESSAGE: { var builder = new AlertDialog.Builder (this, Android.App.AlertDialog.ThemeTraditional); builder.SetIconAttribute (Android.Resource.Attribute.AlertDialogIcon); builder.SetTitle (Resource.String.alert_dialog_two_buttons_title); builder.SetPositiveButton (Resource.String.alert_dialog_ok, OkClicked); builder.SetNegativeButton (Resource.String.alert_dialog_cancel, CancelClicked); return builder.Create (); } case DIALOG_YES_NO_HOLO_LIGHT_MESSAGE: { var builder = new AlertDialog.Builder (this, Android.App.AlertDialog.ThemeHoloLight); builder.SetIconAttribute (Android.Resource.Attribute.AlertDialogIcon); builder.SetTitle (Resource.String.alert_dialog_two_buttons_title); builder.SetPositiveButton (Resource.String.alert_dialog_ok, OkClicked); builder.SetNegativeButton (Resource.String.alert_dialog_cancel, CancelClicked); return builder.Create (); } case DIALOG_YES_NO_LONG_MESSAGE: { var builder = new AlertDialog.Builder (this); builder.SetIconAttribute (Android.Resource.Attribute.AlertDialogIcon); builder.SetTitle (Resource.String.alert_dialog_two_buttons_msg); builder.SetMessage (Resource.String.alert_dialog_two_buttons_msg); builder.SetPositiveButton (Resource.String.alert_dialog_ok, OkClicked); builder.SetNegativeButton (Resource.String.alert_dialog_cancel, CancelClicked); builder.SetNeutralButton (Resource.String.alert_dialog_something, NeutralClicked); return builder.Create (); } case DIALOG_YES_NO_ULTRA_LONG_MESSAGE: { var builder = new AlertDialog.Builder (this); builder.SetIconAttribute (Android.Resource.Attribute.AlertDialogIcon); builder.SetTitle (Resource.String.alert_dialog_two_buttons_msg); builder.SetMessage (Resource.String.alert_dialog_two_buttons2ultra_msg); builder.SetPositiveButton (Resource.String.alert_dialog_ok, OkClicked); builder.SetNegativeButton (Resource.String.alert_dialog_cancel, CancelClicked); builder.SetNeutralButton (Resource.String.alert_dialog_something, NeutralClicked); return builder.Create (); } case DIALOG_LIST: { var builder = new AlertDialog.Builder (this); builder.SetTitle (Resource.String.select_dialog); builder.SetItems (Resource.Array.select_dialog_items, ListClicked); return builder.Create (); } case DIALOG_PROGRESS: { progress_dialog = new ProgressDialog (this); progress_dialog.SetIconAttribute (Android.Resource.Attribute.AlertDialogIcon); progress_dialog.SetTitle (Resource.String.select_dialog); progress_dialog.SetProgressStyle (ProgressDialogStyle.Horizontal); progress_dialog.Max = MAX_PROGRESS; progress_dialog.SetButton (Android.App.Dialog.InterfaceConsts.ButtonPositive, GetText (Resource.String.alert_dialog_ok), OkClicked); progress_dialog.SetButton (Android.App.Dialog.InterfaceConsts.ButtonNegative, GetText (Resource.String.alert_dialog_cancel), CancelClicked); return progress_dialog; } case DIALOG_SINGLE_CHOICE: { var builder = new AlertDialog.Builder (this); builder.SetIconAttribute (Android.Resource.Attribute.AlertDialogIcon); builder.SetTitle (Resource.String.alert_dialog_single_choice); builder.SetSingleChoiceItems (Resource.Array.select_dialog_items2, 0, ListClicked); builder.SetPositiveButton (Resource.String.alert_dialog_ok, OkClicked); builder.SetNegativeButton (Resource.String.alert_dialog_cancel, CancelClicked); return builder.Create (); } case DIALOG_MULTIPLE_CHOICE: { var builder = new AlertDialog.Builder (this); builder.SetIcon (Resource.Drawable.ic_popup_reminder); builder.SetTitle (Resource.String.alert_dialog_multi_choice); builder.SetMultiChoiceItems (Resource.Array.select_dialog_items3, new bool[] { false, true, false, true, false, false, false }, MultiListClicked); builder.SetPositiveButton (Resource.String.alert_dialog_ok, OkClicked); builder.SetNegativeButton (Resource.String.alert_dialog_cancel, CancelClicked); return builder.Create (); } case DIALOG_MULTIPLE_CHOICE_CURSOR: { var projection = new string[] { BaseColumns.Id, Contacts.PeopleColumns.DisplayName, Contacts.PeopleColumns.SendToVoicemail }; var cursor = ManagedQuery (ContactsContract.Contacts.ContentUri, projection, null, null, null); var builder = new AlertDialog.Builder (this); builder.SetIcon (Resource.Drawable.ic_popup_reminder); builder.SetTitle (Resource.String.alert_dialog_multi_choice_cursor); builder.SetMultiChoiceItems (cursor, Contacts.PeopleColumns.SendToVoicemail, Contacts.PeopleColumns.DisplayName, MultiListClicked); return builder.Create (); } case DIALOG_TEXT_ENTRY: { // This example shows how to add a custom layout to an AlertDialog var factory = LayoutInflater.From (this); var text_entry_view = factory.Inflate (Resource.Layout.alert_dialog_text_entry, null); var builder = new AlertDialog.Builder (this); builder.SetIconAttribute (Android.Resource.Attribute.AlertDialogIcon); builder.SetTitle (Resource.String.alert_dialog_text_entry); builder.SetView (text_entry_view); builder.SetPositiveButton (Resource.String.alert_dialog_ok, OkClicked); builder.SetNegativeButton (Resource.String.alert_dialog_cancel, CancelClicked); return builder.Create (); } } return null; }
protected override void OnPreExecute() { base.OnPreExecute(); _progressDialog = new ProgressDialog(_context); _progressDialog.SetTitle("Mandelbrot generation in progress"); _progressDialog.SetMessage("Please wait..."); _progressDialog.SetCancelable(true); _progressDialog.SetProgressStyle(ProgressDialogStyle.Horizontal); _progressDialog.SetButton(-2, "Cancel", CancelClicked); _progressDialog.Show(); }
public ProgressDialog DownloadingProgressDialog(string title, string message) { ProgressDialog progress = new ProgressDialog(context); progress.SetMessage(message); progress.SetTitle(title); progress.SetIcon(Resource.Drawable.Icon); progress.SetButton("Cancel", (sender, args) => { // Close progress dialog progress.Dismiss(); // Stop all downloads client.CancelAsync(); // Remove any language folders that were to be downloaded for (var i = 0; i < downloadQueue.Count; i++) { DeleteLanguagePack(downloadQueue[i]); } // No downloads to be downloaded downloadQueue = new List<string>(); // No files to be download FilesCoutner = 0; // They didn't all download, but set to true anyways allDownloaded = true; if (DownloadedLanguages.Count > 0) { Language = Language; } }); progress.SetProgressStyle(ProgressDialogStyle.Horizontal); progress.SetCancelable(false); progress.SetCanceledOnTouchOutside(false); return progress; }