async Task GetSendSMSPermissionAsync() { //Check to see if any permission in our group is available, if one, then all are const string permission = Manifest.Permission.SendSms; if (CheckSelfPermission(Manifest.Permission.SendSms) == (int)Permission.Granted) { await SMSSend(); return; } //need to request permission if (ShouldShowRequestPermissionRationale(permission)) { var callDialog = new AlertDialog.Builder(this); callDialog.SetTitle("explain"); callDialog.SetMessage("This app needt to send sms so it need sms send permission"); callDialog.SetNeutralButton("yes", delegate { RequestPermissions(PermissionsLocation, RequestLocationId); }); callDialog.SetNegativeButton("no", delegate { }); callDialog.Show(); return; } //Finally request permissions with the list of permissions and Id RequestPermissions(PermissionsLocation, RequestLocationId); }
bool ConfirmationHandler() { var builder = new AlertDialog.Builder(this); builder.SetTitle(Resource.String.crash_confirmation_dialog_title); builder.SetMessage(Resource.String.crash_confirmation_dialog_message); builder.SetPositiveButton(Resource.String.crash_confirmation_dialog_send_button, delegate { Crashes.NotifyUserConfirmation(UserConfirmation.Send); }); builder.SetNegativeButton(Resource.String.crash_confirmation_dialog_not_send_button, delegate { Crashes.NotifyUserConfirmation(UserConfirmation.DontSend); }); builder.SetNeutralButton(Resource.String.crash_confirmation_dialog_always_send_button, delegate { Crashes.NotifyUserConfirmation(UserConfirmation.AlwaysSend); }); builder.Create().Show(); return(true); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.MainView); ViewModel = new PhoneViewModel(); PhoneNumberText = FindViewById <EditText>(Resource.Id.PhoneNumberText); TranslatedText = FindViewById <TextView>(Resource.Id.TranslatedNumber); CallButton = FindViewById <Button>(Resource.Id.CallButton); CallHistoryButton = FindViewById <Button>(Resource.Id.CallHistoryButton); this.Bind(ViewModel, vm => vm.PhoneNumber, v => v.PhoneNumberText.Text); this.OneWayBind(ViewModel, vm => vm.TranslatedNumber, v => v.TranslatedText.Text); this.BindCommand(ViewModel, vm => vm.Call, v => v.CallButton); this.BindCommand(ViewModel, vm => vm.CallHistory, v => v.CallHistoryButton); ViewModel.Call.Subscribe(_ => { var callDialog = new AlertDialog.Builder(this); callDialog.SetMessage("Call " + ViewModel.TranslatedNumber + " ?"); callDialog.SetNeutralButton("Call", delegate { var callIntent = new Intent(Intent.ActionCall); callIntent.SetData(Android.Net.Uri.Parse("tel:" + ViewModel.TranslatedNumber)); StartActivity(callIntent); }); callDialog.SetNegativeButton("Cancel", delegate { }); callDialog.Show(); }); ViewModel.CallHistory.Subscribe(_ => { var intent = new Intent(this, typeof(CallHistoryView)); StartActivity(intent); }); }
}//class public bool?ReadYesNoCancel(string prompt, bool?defaultYes, bool cancelButton) { bool? result = defaultYes; var w = new ManualResetEvent(false); Action exit = () => w.Set(); IDialogInterfaceOnCancelListener lsnrCancel = new IDIOCancelListener { Action = () => { System.Diagnostics.Debug.Assert(result == defaultYes, "NOT equal '" + result + " and '" + defaultYes + "'"); exit(); }, }; EventHandler dlgt = delegate { var bldr = new AlertDialog.Builder(_parent); bldr.SetMessage(prompt); bldr.SetCancelable(true); bldr.SetOnCancelListener(lsnrCancel); bldr.SetPositiveButton("Yes", delegate { result = true; exit(); }); bldr.SetNeutralButton("No", delegate { result = false; exit(); }); if (cancelButton) { bldr.SetNegativeButton("Cancel", delegate { result = null; exit(); }); } var dlg = bldr.Create(); dlg.Show(); }; UiInvokeNoWait(dlgt); w.WaitOne(); return(result); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); // Get our button from the layout resource, // and attach an event to it Button button = FindViewById <Button>(Resource.Id.MyButton); button.Click += delegate { var alert = new AlertDialog.Builder(this); alert.SetTitle("denger alert"); alert.SetMessage("Call me know"); alert.SetNeutralButton("yes dell", delegate { }); alert.SetNegativeButton("Cancel", delegate { }); alert.SetPositiveButton("Yes", delegate { }); alert.Show(); }; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Historico); Persistencia servicio = new Persistencia(this); datos = servicio.recover(); if (datos.Count == 0) { AlertDialog.Builder dialog = new AlertDialog.Builder(this); dialog.SetTitle("ERROR"); dialog.SetMessage("No hay datos almacenados"); dialog.SetNeutralButton("ACEPTAR", (s, EventArgs) => { Finish(); }); dialog.Show(); } else { lista = FindViewById <ListView>(Resource.Id.listHist); lista.ItemClick += OnListItemClick; //lista.Adapter = new ItemsAdapterList(this, datos); } }
public override bool OnShowFileChooser(Android.Webkit.WebView webView, Android.Webkit.IValueCallback filePathCallback, FileChooserParams fileChooserParams) { AlertDialog.Builder alertDialog = new AlertDialog.Builder(MainActivity.Instance); alertDialog.SetTitle("Take picture or choose a file"); alertDialog.SetNeutralButton("Take picture", async(sender, alertArgs) => { try { var photo = await MediaPicker.CapturePhotoAsync(); var uri = await LoadPhotoAsync(photo); filePathCallback.OnReceiveValue(uri); } catch (Exception ex) { Console.WriteLine($"CapturePhotoAsync THREW: {ex.Message}"); } }); alertDialog.SetNegativeButton("Choose picture", async(sender, alertArgs) => { try { var photo = await MediaPicker.PickPhotoAsync(); var uri = await LoadPhotoAsync(photo); filePathCallback.OnReceiveValue(uri); } catch (Exception ex) { Console.WriteLine($"PickPhotoAsync THREW: {ex.Message}"); } }); alertDialog.SetPositiveButton("Cancel", (sender, alertArgs) => { filePathCallback.OnReceiveValue(null); }); Dialog dialog = alertDialog.Create(); dialog.Show(); return(true); }
void CommandSelected(Command c) { // Save for later use if there are more than one target _com = c; if (_com.CmdWith) { // Display WorksWith list to user targets = _com.TargetObjects; if (targets.Count == 0) { // We don't have any target, so display empty text AlertDialog.Builder builder = new AlertDialog.Builder(ctrl); builder.SetTitle(c.Text); builder.SetMessage(_com.EmptyTargetListText); builder.SetNeutralButton(Resource.String.ok, (sender, e) => {}); builder.Show(); } else { // We have a list of commands, so show this to the user string[] targetNames = new string[targets.Count]; for (int i = 0; i < targets.Count; i++) { targetNames[i] = targets[i].Name; } AlertDialog.Builder builder = new AlertDialog.Builder(ctrl); builder.SetTitle(c.Text); builder.SetItems(targetNames, OnTargetListClicked); builder.SetNeutralButton(Resource.String.cancel, (sender, e) => {}); builder.Show(); } } else { // Execute command _com.Execute(); } }
public void OnInfoWindowClick(Marker marker) { LatLng pos = marker.Position; mMap.AnimateCamera(CameraUpdateFactory.NewLatLngZoom(pos, 10)); jsonasd = marker.Title; string icao = marker.Title; Plane plane = (Plane)planesHash[icao]; AlertDialog.Builder alertDialog = new AlertDialog.Builder(this); alertDialog.SetTitle(plane.Icao); alertDialog.SetMessage("Model of plane " + plane.Mdl + "\n" + "Speed of plane: " + plane.Spd + "\n" + "Type of plane: " + plane.Type + "\n" + "From airport: " + plane.From + "\n" + "Towards airport: " + plane.To + "\n"); alertDialog.SetNeutralButton("OK", delegate { alertDialog.Dispose(); }); alertDialog.SetNegativeButton("Follow", delegate { alertDialog.Dispose(); Followplane = true; /*Jsonloader(plane.Lon, plane.Lat, icao);*/ }); alertDialog.Show(); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Main); var instListView = FindViewById <ListView> (Resource.Id.instructorListView); //TODO 3: Fast Scroll instListView.FastScrollEnabled = true; instListView.ItemClick += (sender, e) => { var dialog = new AlertDialog.Builder(this); dialog.SetMessage(InstructorData.Instructors[e.Position].Name); dialog.SetNeutralButton("OK", delegate {}); dialog.Show(); }; InstructorAdapter adapter = new InstructorAdapter(this, InstructorData.Instructors); instListView.Adapter = adapter; }
public override bool OnOptionsItemSelected(IMenuItem item) { switch (item.ItemId) { case Resource.Id.ChatMenu_Notifications: _storageReference = Application.Context.GetSharedPreferences("Token", FileCreationMode.Private); var editor = _storageReference.Edit(); var notificationDIalog = new AlertDialog.Builder(this); notificationDIalog.SetTitle("Notifications"); notificationDIalog.SetPositiveButton("On", (sender, args) => { ShowNotification = true; MuteNotification = false; editor.PutBoolean("Notification", ShowNotification); editor.PutBoolean("NotificationMute", MuteNotification); editor.Apply(); }); notificationDIalog.SetNegativeButton("Off", (sender, args) => { ShowNotification = false; editor.PutBoolean("Notification", ShowNotification); editor.Apply(); }); notificationDIalog.SetNeutralButton("Mute", (sender, args) => { ShowNotification = true; MuteNotification = true; editor.PutBoolean("NotificationMute", MuteNotification); editor.PutBoolean("Notification", ShowNotification); editor.Apply(); }); notificationDIalog.Show(); break; default: break; } return(base.OnOptionsItemSelected(item)); }
/// <summary> /// 操作提示对话框 /// </summary> private void OperateDialogBox(object sender, EventArgs e) { var button = (Button)sender; //对话框 var callDialog = new AlertDialog.Builder(this); //对话框内容 callDialog.SetMessage("确定要进行" + button.Text + "吗?"); //确定按钮 callDialog.SetNeutralButton("确定", delegate { if (button.Text == "重置系统") { InitSqlDB(db); } }); //取消按钮 callDialog.SetNegativeButton("取消", delegate { }); //显示对话框 callDialog.Show(); }
protected override void OnStart() { base.OnStart(); InitService(); var button1 = FindViewById <Button> (Resource.Id.buttonCalc); button1.Click += (sender, e) => { if (IsBound) { var text1 = FindViewById <EditText> (Resource.Id.value1); var text2 = FindViewById <EditText> (Resource.Id.value2); var result = FindViewById <TextView> (Resource.Id.result); int v1; int v2; int v3; if (Int32.TryParse(text2.Text, out v2) && Int32.TryParse(text1.Text, out v1)) { v3 = Service.Add(v1, v2); } else { v3 = 0; var builder = new AlertDialog.Builder(this); builder.SetMessage("Spaces or special character are not allowed"); builder.SetNeutralButton("OK", (source, eventArgs) => {}); builder.Show(); } result.Text = v3.ToString(); } else { Log.Warn(Tag, "The AdditionService is not bound"); } }; }
private void ShowDialogPlayAgain() { if (_playAgain) { _playAgain = false; RunOnUiThread(() => { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.SetTitle("Coins Earned On Wins"); builder.SetMessage(" 5 Gifts = 1 Gold"); builder.SetCancelable(false); builder.SetPositiveButton("Play Again", delegate { PlayAgain(builder); }); builder.SetNeutralButton("Back", delegate { GoBack(builder); }); builder.Show(); }); } else { GoToMenu(); } }
public override Dialog OnCreateDialog(Bundle savedState) { this.EnsureBindingContextIsSet(); view = this.BindingInflate(Resource.Layout.learned_spell_dialog, null); AssetManager assets = this.Context.Assets; using (StreamReader sr = new StreamReader(assets.Open("spells.json"))) { var content = sr.ReadToEnd(); spells = JsonConvert.DeserializeObject <IList <RootObject> >(content); } var spellNames = spells.Select(x => x.name).ToList(); AutoCompleteTextView textView = view.FindViewById <AutoCompleteTextView>(Resource.Id.autocomplete_spell); var adapter = new ArrayAdapter <String>(Context, Resource.Layout.autocomplete_row, spellNames); textView.ItemClick += TextView_ItemClick; textView.Adapter = adapter; var dialog = new AlertDialog.Builder(Activity); dialog.SetTitle("Learned spell Dialog"); dialog.SetView(view); if (ViewModel.IsEditMode) { dialog.SetNeutralButton("Delete", (s, a) => { ViewModel.DeleteCommand.Execute(); }); } dialog.SetNegativeButton("Cancel", (s, a) => { }); dialog.SetPositiveButton("OK", (s, a) => ViewModel.SaveCommand.Execute() ); return(dialog.Create()); }
private async Task CreateAccount(String url) { client.MaxResponseContentBufferSize = 256000; var uri = new Uri(url); string password = passwordText.Text.ToString(); string confirmPassword = confirmationPassword.Text.ToString(); if (verifyPassword(password, confirmPassword)) { createUser(); var json = JsonConvert.SerializeObject(newUser); var content = new StringContent(json, Encoding.UTF8, "application/json"); HttpResponseMessage response = null; response = await client.PostAsync(uri, content); if (response.IsSuccessStatusCode) { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.SetTitle("Account Created!"); alert.SetMessage("Welcome to BooksToGo! Click Login to return to the main page."); alert.SetNeutralButton("LOGIN", (senderAlert, args) => { Intent nextActivity = new Intent(this, typeof(MainActivity)); StartActivity(nextActivity); }); Dialog dialog = alert.Create(); dialog.Show(); } } else { // creationResponse.SetText(Int32.Parse("Password and Confirmation Don't Match!")); } }
public Task <MessageResult> ShowDialog(string Title, string Message, bool SetCancelable = false, bool SetInverseBackgroundForced = false, MessageResult PositiveButton = MessageResult.OK, MessageResult NegativeButton = MessageResult.NONE, MessageResult NeutralButton = MessageResult.NONE, int IconAttribute = Android.Resource.Attribute.AlertDialogIcon) { var tcs = new TaskCompletionSource <MessageResult>(); var builder = new AlertDialog.Builder(mcontext); builder.SetIconAttribute(IconAttribute); builder.SetTitle(Title); builder.SetMessage(Message); builder.SetInverseBackgroundForced(SetInverseBackgroundForced); builder.SetCancelable(SetCancelable); builder.SetPositiveButton((PositiveButton != MessageResult.NONE) ? PositiveButton.ToString() : string.Empty, (senderAlert, args) => { tcs.SetResult(PositiveButton); }); builder.SetNegativeButton((NegativeButton != MessageResult.NONE) ? NegativeButton.ToString() : string.Empty, delegate { tcs.SetResult(NegativeButton); }); builder.SetNeutralButton((NeutralButton != MessageResult.NONE) ? NeutralButton.ToString() : string.Empty, delegate { tcs.SetResult(NeutralButton); }); Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { }); Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { builder.Show(); }); // builder.Show(); return(tcs.Task); }
public MainApp(IntPtr javaReference, JniHandleOwnership transfer) : base(javaReference, transfer) { // Catch unhandled exceptions // Found at http://xandroid4net.blogspot.de/2013/11/how-to-capture-unhandled-exceptions.html // Add an exception handler for all uncaught exceptions. AndroidEnvironment.UnhandledExceptionRaiser += AndroidUnhandledExceptionHandler; AppDomain.CurrentDomain.UnhandledException += ApplicationUnhandledExceptionHandler; // Save prefernces instance Main.Prefs = new PreferenceValues(PreferenceManager.GetDefaultSharedPreferences(this)); // Get path from preferences or default path string path = Main.Prefs.GetString("filepath", Path.Combine(global::Android.OS.Environment.ExternalStorageDirectory.AbsolutePath, "WF.Player")); try { if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } } catch { } if (!Directory.Exists(path)) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.SetTitle(GetString(Resource.String.main_error)); builder.SetMessage(String.Format(GetString(Resource.String.main_error_directory_not_found), path)); builder.SetCancelable(true); builder.SetNeutralButton(Resource.String.ok, (obj, arg) => { }); builder.Show(); } else { Main.Path = path; Main.Prefs.SetString("filepath", path); } }
void CheckData() { ISharedPreferences pref = PreferenceManager.GetDefaultSharedPreferences(this); int rate = pref.GetInt("Rateing", 0); if (rate == 0) { var callDialog = new AlertDialog.Builder(this); callDialog.SetTitle("تقييم التطبيق"); callDialog.SetMessage("(هل تريد تقييم التطبيق؟(رجاء تقييم التطبيق رايك يهمنالتطوير التطبيق لافضل"); callDialog.SetNeutralButton("نعم", delegate { saveData(1); var ur = Android.Net.Uri.Parse("https://play.google.com/store/apps/details?id=com.mohameedsalah.LearnEnglish"); var intent2 = new Intent(Intent.ActionView, ur); StartActivity(intent2); }); callDialog.SetNegativeButton("لا شكرا", delegate { this.FinishAffinity(); }); callDialog.Show(); } if (rate == 1) { Android.App.AlertDialog.Builder alert = new Android.App.AlertDialog.Builder(this); alert.SetTitle("تاكيد الخروج"); alert.SetMessage("الخروج من البرنامج"); alert.SetPositiveButton("نعم", (senderAlert, args) => { this.FinishAffinity(); }); alert.SetNegativeButton("لا", (senderAlert, args) => { }); Dialog dialog = alert.Create(); dialog.Show(); } }
public static void ShowError(this Activity activity, string title, string message) { /* * try/catch added to solve * Android.Views.WindowManagerBadTokenException: * Unable to add window -- token android.os.BinderProxy@52907c38 is not valid; * is your activity running? * * https://bugzilla.xamarin.com/show_bug.cgi?id=37870 * https://forums.xamarin.com/discussion/11491/xamarin-auth-alway-throws-exception-on-android * * should be also prevented by checking if the activity is finishing (in that case avoid adding the alert dialog) */ try { if (activity.IsFinishing) { return; } var b = new AlertDialog.Builder(activity); b.SetMessage(message); b.SetTitle(title); b.SetNeutralButton("OK", (s, e) => { ((AlertDialog)s).Cancel(); }); var alert = b.Create(); alert.Show(); } catch (WindowManagerBadTokenException ex) { string msg = ex.Message; global::Android.Util.Log.Error("Xamarin.Auth", "Error: {0}:{1} - {2}", title, message, msg); } return; }
private bool verifyPassword(string password, string confirmationPassword) { if (password.Equals(confirmationPassword)) { return(true); } else { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.SetTitle("PASSWORD ERROR"); alert.SetMessage("Password and Confirmation Password do not match. Please make correction."); alert.SetNeutralButton("Try Again", (senderAlert, args) => { }); Dialog dialog = alert.Create(); dialog.Show(); return(false); } }
public void Show() { AlertDialog.Builder dialog = new AlertDialog.Builder(_context); dialog.SetTitle(Title); if (string.IsNullOrWhiteSpace(Message) == false) { dialog.SetMessage(Message); } if (Content != null) { dialog.SetView(Content); } dialog.SetPositiveButton(Positive, OnPositiveProc); dialog.SetNegativeButton(Negative, OnNegativeProc); if (string.IsNullOrWhiteSpace(Neutral) == false) { dialog.SetNeutralButton(Neutral, OnNeutralProc); } dialog.SetOnCancelListener(this); dialog.SetCancelable(IsCancellable); _dialog = dialog.Create(); Reshow(); }
private void deleteDb(object sender, EventArgs e) { AlertDialog.Builder alertDialog = new AlertDialog.Builder(this); alertDialog.SetTitle("Delete Tracker"); alertDialog.SetMessage("Do you like to delete this tracker?"); alertDialog.SetNeutralButton("OK", delegate { try { DeleteUserAsync(selectedAccount.uid); } catch (Exception i) { Toast.MakeText(this, "No Tracker Selected", ToastLength.Short).Show(); } }); alertDialog.SetNegativeButton("Cancel", delegate { alertDialog.Dispose(); }); alertDialog.Show(); }
private void btnProjectDelete_Click(object sender, EventArgs e) { // Confirm with user var dialogBuilder = new AlertDialog.Builder(this); dialogBuilder.SetTitle("Delete Project?!"); dialogBuilder.SetMessage("Are you sure you want to delete the '" + _project.Name + "' project? (Can't be undone...)"); dialogBuilder.SetNeutralButton("Cancel", (x, y) => { // Do nothing as cancelled }); dialogBuilder.SetNegativeButton("DELETE", (x, y) => { // Send delete request TaskManagerAPI.Project.DeleteProject(Token.AuthToken, _projectId); // If this successds return to project list var projectListIntent = new Intent(this, typeof(ProjectListActivity)); StartActivity(projectListIntent); return; }); dialogBuilder.Show(); }
private void Ws_reviewCompleted(object sender, webService.reviewCompletedEventArgs e) { if ("sucess".Equals(e.Result)) { var callDialog = new AlertDialog.Builder(this); callDialog.SetTitle("revue"); callDialog.SetMessage("merci chers client pour votre avis"); callDialog.SetNeutralButton("Ok", delegate { }); callDialog.Show(); } else { var callDialog = new AlertDialog.Builder(this); callDialog.SetTitle("erreur"); callDialog.SetMessage("vous etez deja donnee votre avis pour ce bricoleur"); callDialog.SetNeutralButton("Ok", delegate { }); callDialog.Show(); } }
static public Task <WrongPasswordOption> wrongPasswordAsync() { var completion = new TaskCompletionSource <WrongPasswordOption>(); AlertDialog.Builder dialog = new AlertDialog.Builder(ActivitiesManager.Instance.current); dialog.SetTitle("Wrong Password"); dialog.SetMessage("Wrong Password"); dialog.SetPositiveButton("Try again", (sender, e) => { completion.SetResult(WrongPasswordOption.TRYAGAIN); }); dialog.SetNegativeButton("Delete Device", (sender, e) => { completion.SetResult(WrongPasswordOption.DELETE); }); dialog.SetNeutralButton("Skip", (sender, e) => { completion.SetResult(WrongPasswordOption.SKIP); }); dialog.Create().Show(); return(completion.Task); }
//BtToast evento btYesNO private void BtYesNo_Click(object sender, EventArgs e) { //Objeto AlertDialog.Builder alerta = new AlertDialog.Builder(this); //Titulo alerta.SetTitle("Yes NO"); //icon alerta.SetIcon(Android.Resource.Drawable.IcLockIdleLock); //ms alerta.SetMessage("Mensagem"); //evento //positivo alerta.SetPositiveButton("YES", (senderAlert, arg) => { Toast.MakeText(this, "Clicou em yes", ToastLength.Short).Show(); }); //negativo alerta.SetNegativeButton("NO", (senderAlert, args) => { Toast.MakeText(this, "Clicou em no", ToastLength.Short).Show(); }); //neutro alerta.SetNeutralButton("Neutro", (senderAlert, args) => { Toast.MakeText(this, "Clicou em no", ToastLength.Short).Show(); }); //mostra alerta.Show(); }
public void ThankuYouAlert() { AlertDialog.Builder aler = new AlertDialog.Builder(this, Resource.Style.MyDialogTheme); aler.SetTitle("Sorry"); aler.SetMessage("This Feature is available for VIP Users only"); aler.SetPositiveButton("Login", delegate { var intent = new Intent(this, typeof(LoginActivity)); StartActivity(intent); }); aler.SetNegativeButton("KnowMore", delegate { var uri = Android.Net.Uri.Parse("https://hangoutz.azurewebsites.net/index.html"); var intent = new Intent(Intent.ActionView, uri); StartActivity(intent); }); aler.SetNeutralButton("Cancel", delegate { }); Dialog dialog1 = aler.Create(); dialog1.Show(); }
private void BtnPhone_Click(object sender, EventArgs e) { //创建 是否类型提示框 var callDialog = new AlertDialog.Builder(this); //提示框信息 callDialog.SetMessage("是否开始通话?"); //确定按钮的文字和事件 callDialog.SetNeutralButton("通话", delegate { //创建打电话的事件 Intent call = new Intent(Intent.ActionCall); EditText txtPhone = FindViewById <EditText>(Resource.Id.txtPhone); //要打给的电话号是多少 call.SetData(Android.Net.Uri.Parse("tel:" + txtPhone.Text)); //执行这个事件 StartActivity(call); }); //取消按钮的文字和事件 callDialog.SetNegativeButton("取消", delegate { }); //显示出来。 callDialog.Show(); }
public Task <MessageResult> ShowDialog(string title, string message, bool setCancelable = false, bool setInverseBackgroundForced = false, MessageResult positiveButton = MessageResult.Ok, MessageResult negativeButton = MessageResult.None, MessageResult neutralButton = MessageResult.None) { var tcs = new TaskCompletionSource <MessageResult>(); var builder = new AlertDialog.Builder(_context); //builder.SetIconAttribute(iconAttribute); builder.SetTitle(title); builder.SetMessage(message); //builder.SetInverseBackgroundForced(setInverseBackgroundForced); builder.SetCancelable(setCancelable); string GetBtnText(MessageResult res) => res != MessageResult.None ? res.ToString() : string.Empty; builder.SetPositiveButton(GetBtnText(positiveButton), delegate { tcs.SetResult(positiveButton); }); builder.SetNegativeButton(GetBtnText(negativeButton), delegate { tcs.SetResult(negativeButton); }); builder.SetNeutralButton(GetBtnText(neutralButton), delegate { tcs.SetResult(neutralButton); }); builder.Show(); // builder.Show(); return(tcs.Task); }
void AddBinaryOrAsk(Uri filename) { string strItem = GetFileName(filename); if (String.IsNullOrEmpty(strItem)) { strItem = "attachment.bin"; } if (State.Entry.Binaries.Get(strItem) != null) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.SetTitle(GetString(Resource.String.AskOverwriteBinary_title)); builder.SetMessage(GetString(Resource.String.AskOverwriteBinary)); builder.SetPositiveButton(GetString(Resource.String.AskOverwriteBinary_yes), (dlgSender, dlgEvt) => { AddBinary(filename, true); }); builder.SetNegativeButton(GetString(Resource.String.AskOverwriteBinary_no), (dlgSender, dlgEvt) => { AddBinary(filename, false); }); builder.SetNeutralButton(GetString(Android.Resource.String.Cancel), (dlgSender, dlgEvt) => {}); Dialog dialog = builder.Create(); dialog.Show(); } else { AddBinary(filename, true); } }
void DisplayMessageBox( string title, string message, Note.MessageBoxResult onResult ) { Rock.Mobile.Threading.Util.PerformOnUIThread( delegate { AlertDialog.Builder dlgAlert = new AlertDialog.Builder( Rock.Mobile.PlatformSpecific.Android.Core.Context ); dlgAlert.SetTitle( title ); dlgAlert.SetMessage( message ); dlgAlert.SetNeutralButton( GeneralStrings.Yes, delegate { onResult( 0 ); }); dlgAlert.SetPositiveButton( GeneralStrings.No, delegate(object sender, DialogClickEventArgs ev ) { onResult( 1 ); } ); dlgAlert.Create( ).Show( ); } ); }