public static AlertDialog ShowQuestion(this Activity activity, string title, string message, string positiveButton, string negativeButton, Action positive, Action negative) { AlertDialog dialog = null; var builder = new AlertDialog.Builder(activity); builder.SetTitle(title); builder.SetMessage(message); builder.SetPositiveButton(positiveButton, (s, e) => { dialog.Cancel(); dialog.Dismiss(); if (positive != null) { positive(); } }); builder.SetNegativeButton(negativeButton, (s, e) => { dialog.Cancel(); dialog.Dismiss(); if (negative != null) { negative(); } }); dialog = builder.Show(); return(dialog); }
private void ListTaskOnLongClick(object sender, AdapterView.ItemLongClickEventArgs arg) { LayoutInflater layoutInflater = LayoutInflater.From(this); View promptView = layoutInflater.Inflate(Resource.Layout.TaskMenu, null); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); alertDialogBuilder.SetView(promptView); alertDialogBuilder.SetTitle("Menu"); int item = database.getId(arg.Position); Button verwijder = (Button)promptView.FindViewById <Button>(Resource.Id.buttonMenuDel); Button annuleer = (Button)promptView.FindViewById <Button>(Resource.Id.buttonMenuCancel); AlertDialog alert = alertDialogBuilder.Create(); verwijder.Click += (object senderVerw, System.EventArgs verw) => { database.DeleteFromTable(item); alert.Cancel(); ListView taskList = FindViewById <ListView>(Resource.Id.listView1); List <string> taken = database.getFromTable(datum); ArrayAdapter adapter = new ArrayAdapter <String>(this, Resource.Layout.TextViewItem, taken); taskList.Adapter = adapter; }; annuleer.Click += (object senderVerw, System.EventArgs verw) => { alert.Cancel(); }; alert.Show(); }
private void DeleteOptionClicked(object s, EventArgs e, int position, AlertDialog optionBox) { try { AlertDialog.Builder builder = new AlertDialog.Builder(this); var alterDialog = builder.Create(); alterDialog.SetTitle("Delete"); alterDialog.SetIcon(Resource.Drawable.Icon); alterDialog.SetMessage("Do you want to delete this item?"); //alterDialog.SetCancelable(false); alterDialog.SetButton("Yes", (o, args) => { var item = _listView.GetItemAtPosition(position); if (item != null) { _adapter.RemoveItem(position); RunOnUiThread(() => { _adapter.NotifyDataSetChanged(); }); } }); alterDialog.SetButton2("No", (o, args) => { }); alterDialog.Show(); optionBox.Cancel(); } catch (Exception ex) { Log.Error("Exception:", ex.Message + "|StackTrace:" + ex.StackTrace); } }
public void ShowAlertAndEnableOverscan() { /** * Show a confirmation dialog and enable overscan. */ OverscanUtil.EnableOverscan(); if (!OverscanUtil.DialogShown) { System.Console.WriteLine("Showing alert dialog"); AlertDialog confirmAlertDialog = builder.Create(); confirmAlertDialog.SetCanceledOnTouchOutside(false); Handler mHandler = new Handler((Android.OS.Message msg) => { switch (msg.What) { case 0: if (confirmAlertDialog != null && confirmAlertDialog.IsShowing) { confirmAlertDialog.Cancel(); DisableOverscan(); } break; default: break; } }); confirmAlertDialog.Show(); mHandler.SendEmptyMessageDelayed(0, DIALOG_TIMEOUT); OverscanUtil.DialogShown = true; } }
private void DeleteOptionClicked(object s, EventArgs e, int position, AlertDialog optionBox) { AlertDialog.Builder builder = new AlertDialog.Builder(this); var deleteBox = builder.Create(); deleteBox.SetTitle("Delete"); deleteBox.SetIcon(Resource.Drawable.Icon); deleteBox.SetMessage("Do you want to delete this item?"); //deleteBox.SetCancelable(false); deleteBox.SetButton("Yes", (p, argsp) => { var item = _listView.GetItemAtPosition(position); if (item != null) { _adapter.RemovePrice(position); _adapter.RemoveMarkMap(position); _adapter.RemoveItem(position); if (_adapter.GetListCount() <= 0) { FindViewById <View>(Resource.Id.TotalLayout).Visibility = ViewStates.Invisible; } RunOnUiThread(() => { _adapter.NotifyDataSetChanged(); }); } }); deleteBox.SetButton2("No", (p, argsp) => { }); deleteBox.Show(); optionBox.Cancel(); }
private void BtnDeduction_Click(object sender, EventArgs e) { var btn = (Button)sender; var Tag = btn.Tag.ToString(); var ruleCode = Tag.Split(',')[0]; var subRuleCode = Tag.Split(',')[1]; if (string.IsNullOrEmpty(subRuleCode)) { subRuleCode = null; } var examScore = Singleton.GetExamScore; var examItemCode = dataService.GetExamItemCode(currentExam); if (!string.IsNullOrEmpty(RGSelectExamItem)) { examItemCode = dataService.GetExamItemCode(RGSelectExamItem); examScore.BreakRule(examItemCode, RGSelectExamItem, ruleCode, subRuleCode); } else { examScore.BreakRule(examItemCode, currentExam, ruleCode, subRuleCode); } //需要根据选择的ExamItemCode 进行扣分 //取消对话框 alertDialog.Cancel(); }
protected virtual void AddStyleButton_Click(object sender, EventArgs e) { if (!isClicked) { try { styleBtnFunc(); if (!isEditMode) { HtmlBuilder.Instance.PageStructureDictionary.Add(Convert.ToInt32(position.Text), element); } Intent intent = new Intent(this, typeof(StyleActivity)); intent.PutExtra("key", Convert.ToInt32(position.Text)); StartActivity(intent); isClicked = true; } catch (Exception ex) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.SetMessage(ex.Message) .SetTitle("Error"); AlertDialog dialog = builder.Create(); builder.SetPositiveButton("OK", (c, ev) => { dialog.Cancel(); }); dialog.Show(); } } }
private void ShowAlert(Context context, string title, Bitmap bitmap) { AlertDialog dialog = null; LayoutInflater inflater = (LayoutInflater)context.GetSystemService(Context.LayoutInflaterService); View dialoglayout = inflater.Inflate(Resource.Layout.activity_qr_result, null); imgQR = dialoglayout.FindViewById <ImageView>(Resource.Id.imgResult); imgQR.SetImageBitmap(bitmap); dialog = new AlertDialog.Builder(context) .SetTitle(title) .SetPositiveButton("Save", (sender, e) => { Java.IO.File storagePath = context.GetExternalFilesDir(Android.OS.Environment.DirectoryPictures); string datetime = DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss"); string path = System.IO.Path.Combine(storagePath.ToString(), $"QR_{datetime}.jpg"); SaveImage(bitmap, path); }) .SetNegativeButton("Cancel", (sender, e) => { dialog.Cancel(); }) .SetView(dialoglayout) .Create(); dialog.Show(); }
public void Close() { if (alertDialog != null) { alertDialog.Cancel(); } }
public Java.Lang.String UITestBackdoorScan(string param) { var expectedFormat = BarcodeFormat.QR_CODE; Enum.TryParse(param, out expectedFormat); var opts = new MobileBarcodeScanningOptions { PossibleFormats = new List <BarcodeFormat> { expectedFormat } }; var barcodeScanner = new MobileBarcodeScanner(); Console.WriteLine("Scanning " + expectedFormat); //Start scanning barcodeScanner.Scan(opts).ContinueWith(t => { var result = t.Result; var format = result?.BarcodeFormat.ToString() ?? string.Empty; var value = result?.Text ?? string.Empty; RunOnUiThread(() => { AlertDialog dialog = null; dialog = new AlertDialog.Builder(this) .SetTitle("Barcode Result") .SetMessage(format + "|" + value) .SetNeutralButton("OK", (sender, e) => { dialog.Cancel(); }).Create(); dialog.Show(); }); }); return(new Java.Lang.String()); }
public static AlertDialog ShowInformation(this Activity activity, string title, string message, string buttonText, Action button = null) { AlertDialog dialog = null; var builder = new AlertDialog.Builder(activity); builder.SetTitle(title); builder.SetMessage(message); builder.SetNegativeButton(buttonText, (s, e) => { if (dialog == null) { return; } dialog.Cancel(); dialog.Dismiss(); if (button != null) { button(); } }); dialog = builder.Show(); return(dialog); }
private void ListTaskOnLongClick(object sender, AdapterView.ItemLongClickEventArgs arg) { LayoutInflater layoutInflater = LayoutInflater.From(this); View promptView = layoutInflater.Inflate(Resource.Layout.TaskMenu, null); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); alertDialogBuilder.SetView(promptView); alertDialogBuilder.SetTitle("Menu"); int positie = 0; String zoeken = myItems[arg.Position]; foreach (string test in taken) { if (test == zoeken) { break; } positie++; } int item = database.getId(positie); Button verwijder = (Button)promptView.FindViewById <Button>(Resource.Id.buttonMenuDel); Button annuleer = (Button)promptView.FindViewById <Button>(Resource.Id.buttonMenuCancel); AlertDialog alert = alertDialogBuilder.Create(); verwijder.Click += (object senderVerw, System.EventArgs verw) => { database.DeleteFromTable(item); alert.Cancel(); myItems = ResetAndFillUpList(myItems); taken = database.getFromTable(datum); int i = 0; foreach (string test in taken) { int indextest = Convert.ToInt32(database.getBeginuren(i).Hours); myItems[indextest] = test; i++; } ArrayAdapter <string> adapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1, myItems); myListView.Adapter = adapter; }; annuleer.Click += (object senderVerw, System.EventArgs verw) => { alert.Cancel(); }; alert.Show(); }
//如果没有信号 private void Btn_Click(object sender, EventArgs e) { alertStudentInfoDialog.Cancel(); IsPlay = false; //timer 停止 timer.Change(0, -1); Task.Run(() => { messager.Send <PrepareDrivingFinishedMessage>(new PrepareDrivingFinishedMessage()); }); }
public virtual void OnInteractionFinished(object sender, InteractionEventArgs args) { if (alertDialog != null) { alertDialog.Cancel(); } this.Dismiss(); }
void CancelDialog() { if (_dialog?.IsShowing ?? false) { _dialog?.Cancel(); } _dialog = null; }
void handllerNotingButton(object sender, DialogClickEventArgs e) { AlertDialog objAlertDialog = sender as AlertDialog; var uri = Android.Net.Uri.Parse(listBook[positionGlobal].url); var intent = new Intent(Intent.ActionView, uri); contex.StartActivity(intent); objAlertDialog.Cancel(); }
protected void Okienko_Dodaj(int position) { AlertDialog.Builder builder = new AlertDialog.Builder(mContext); AlertDialog alertDialog = builder.Create(); alertDialog.SetTitle("Czy chcesz dodaæ produkt do koszyka?"); alertDialog.SetMessage(mItems[position].Name + "\nCena: " + mItems[position].Price); alertDialog.SetButton2("Tak", (s, ev) => { Kosz.Add_produkt(mItems[position]); alertDialog.Cancel(); }); alertDialog.SetButton("Nie", (s, ev) => { alertDialog.Cancel(); }); alertDialog.Show(); }
private void PlayerList_ItemClick(object sender, AdapterView.ItemClickEventArgs e) { ListView listview = (ListView)sender; DetailedPlayerListAdapter adapter = listview.Adapter as DetailedPlayerListAdapter; DbPlayer player = adapter.GetItem(e.Position); zoneAdapter.Add(player); addPlayerAction.Invoke(player); zoneAdapter = null; alert.Cancel(); }
protected override void OnPause() { base.OnPause(); OverridePendingTransition(Resource.Animation.slide_in_left, Resource.Animation.slide_out_right); if (apiClient.IsConnected) { LocationServices.FusedLocationApi.RemoveLocationUpdates(apiClient, this); apiClient.Disconnect(); } try { if (builder != null) { builder.Cancel(); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
public static void DisplayAlert(Context putThis, string title, string message, string buttonText = "OK") { AlertDialog.Builder dialog = new AlertDialog.Builder(putThis); AlertDialog alert = dialog.Create(); alert.SetTitle(title); alert.SetMessage(message); alert.SetButton(buttonText, (c, ev) => { alert.Cancel(); }); alert.Show(); }
public static void OpenAlert(Context context, string title, string message) { AlertDialog dialog = null; dialog = new AlertDialog.Builder(context) .SetTitle(title) .SetMessage(message) .SetNeutralButton("OK", (sender, e) => { dialog.Cancel(); }).Create(); dialog.Show(); }
public void InvalidWord(string wordtext) { alertDialog = new AlertDialog.Builder(this).Create(); EditText txtEntrName = new EditText(this); txtEntrName.Text = wordtext; txtEntrName.SetFilters(new IInputFilter[] { new InputFilterLengthFilter(10) }); alertDialog.SetTitle("Invalid characters. Letters only"); alertDialog.SetMessage("Letters only. Numbers, symbols and spaces are invalid"); alertDialog.SetView(txtEntrName); alertDialog.SetButton("Play", (s, ev) => { word = txtEntrName.Text; word = word.ToUpper(); var answerLetters = word.ToCharArray(); if (Regex.IsMatch(word, @"^[a-zA-Z]+$")) { //Set the word display to blanks for word.length for (int i = 0; i < word.Length; i++) { // Create new Textview for each letter lblWord = new TextView(this); lblWordArrayList.Add(lblWord); lblWord.Text = "_"; lblWord.Id = i; lblWord.SetTypeface(tf, TypefaceStyle.Normal); lblWord.SetPadding(15, 5, 15, 5); lblWord.SetTextColor(Color.Black); lblWord.TextSize = 25; linearWordAnswer.AddView(lblWord); } lblWordArrayList.ToArray(); alertDialog.Cancel(); } else { InvalidWord(word); } }); alertDialog.SetButton2("Main Menu", (s, ev) => { Finish(); }); alertDialog.SetCancelable(false); alertDialog.Show(); }
private void AlertDialogButton_Ok_Click(object sender, EventArgs e) { Model.Files temp = Model.Files.ResFile; var DirName = view.FindViewById <EditText>(Resource.Id.editTextDialogAlert).Text; if (DirName != null) { Toast.MakeText(this, temp.NewDirectory(DirName) ? "Каталог: " + DirName + " успешно создан!" : "Ошибка!", ToastLength.Long).Show(); dialog.Cancel(); } }
private void EditListNameOptionClicked(object s, EventArgs e, int position, AlertDialog optionBox) { AlertDialog.Builder builder = new AlertDialog.Builder(this); var editBox = builder.Create(); editBox.SetTitle("Update Category Name"); editBox.SetIcon(Resource.Drawable.Icon); editBox.SetMessage("Enter New Name: "); var view = editBox.LayoutInflater.Inflate(Resource.Layout.LimitedInputBoxString, null); var inputTextField = view.FindViewById <EditText>(Resource.Id.LimitedEditTextString); editBox.SetView(view); //editBox.SetCancelable(false); var oldListName = (string)_listView.GetItemAtPosition(position); inputTextField.Text = oldListName; editBox.SetButton("Done", (o, args) => { if (!string.IsNullOrEmpty(oldListName)) { var newListName = inputTextField.Text; if (!string.IsNullOrEmpty(newListName)) { _adapter.SetItemName(position, newListName); ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(this); var oldSaveItem = oldListName + position; var storedItemString = prefs.GetString(oldSaveItem, null); var markingListString = prefs.GetString(oldSaveItem + "MarkingList", null); var priceListString = prefs.GetString(oldSaveItem + "PriceList", null); ISharedPreferencesEditor editor = prefs.Edit(); var newSaveItem = newListName + position; editor.PutString(newSaveItem, storedItemString); editor.PutString(newSaveItem + "MarkingList", markingListString); editor.PutString(newSaveItem + "PriceList", priceListString); //editor.PutString(_listName + "total", Convert.ToString(_adapter.GetPriceTotal())); editor.Apply(); // applies changes synchronously on older APIs } RunOnUiThread(() => { _adapter.NotifyDataSetChanged(); }); } }); editBox.SetButton2("Cancle", (o, args) => { }); editBox.Show(); optionBox.Cancel(); }
void ShowMessage(string msg) { this.RunOnUiThread(() => { AlertDialog ad = null; var adBuilder = new AlertDialog.Builder(this); adBuilder.SetTitle("Barcode"); adBuilder.SetMessage(msg); adBuilder.SetNegativeButton("OK", (s, e) => { ad.Dismiss(); ad.Cancel(); }); ad = adBuilder.Create(); ad.Show(); }); }
protected void Okienko_Usun(int position) { try { AlertDialog.Builder builder = new AlertDialog.Builder(mContext); AlertDialog alertDialog = builder.Create(); alertDialog.SetTitle("Czy chcesz usun¹æ produkt z koszyka?"); alertDialog.SetMessage(mItems[position].Name + "\nCena: " + mItems[position].Price); alertDialog.SetButton2("Tak", (s, ev) => { Kosz.Del_produkt(mItems[position]); NotifyDataSetChanged(); alertDialog.Cancel(); }); alertDialog.SetButton("Nie", (s, ev) => { alertDialog.Cancel(); }); alertDialog.Show(); } catch { NotifyDataSetChanged(); } }
/// <summary> /// Input the title and message for alert /// </summary> /// <param name="title"></param> /// <param name="message"></param> public void ShowAlert(String title, string message) { Android.App.AlertDialog.Builder alertDiaglog = new Android.App.AlertDialog.Builder(context); AlertDialog alert = alertDiaglog.Create(); alert.SetTitle(title); alert.SetMessage(message); alert.SetButton("OK", (c, ev) => { // Ok button click task alert.Hide(); }); alert.SetButton2("Cancel", (c, ev) => { // Ok button click task alert.Cancel(); }); alert.Show(); }
private void WarnForLocationPermissionDenial() { AlertDialog alertDialog = null; var builder = new AlertDialog.Builder(this); builder.SetPositiveButton("ALLOW", (senderAlert, args) => { ActivityCompat.RequestPermissions(this, new string[] { Manifest.Permission.AccessFineLocation }, locationPermissionId); }); builder.SetNegativeButton("CANCEL", (senderAlert, args) => { alertDialog.Cancel(); alertDialog.Dismiss(); }); builder.SetTitle("Location Permission"); builder.SetMessage("Not granting location permission will screw my efforts"); alertDialog = builder.Create(); alertDialog.Show(); }
private void EditOptionClicked(object s, EventArgs e, int position, AlertDialog optionBox) { AlertDialog.Builder builder = new AlertDialog.Builder(this); var editBox = builder.Create(); editBox.SetTitle("Update Item"); editBox.SetIcon(Resource.Drawable.Icon); editBox.SetMessage("Enter New Values: "); var view = editBox.LayoutInflater.Inflate(Resource.Layout.ItemEditLayout, null); var inputTextFieldName = view.FindViewById <EditText>(Resource.Id.EditedNameBox); var inputTextFieldPrice = view.FindViewById <EditText>(Resource.Id.EditedPriceBox); inputTextFieldPrice.InputType = Android.Text.InputTypes.ClassNumber; editBox.SetView(view); //editBox.SetCancelable(false); var oldListName = (string)_listView.GetItemAtPosition(position); var oldPrice = Convert.ToString(_adapter.GetPrice(position)); inputTextFieldName.Text = oldListName; inputTextFieldPrice.Text = oldPrice; editBox.SetButton("Done", (o, args) => { if (!string.IsNullOrEmpty(oldListName)) { var newListName = inputTextFieldName.Text; if (!string.IsNullOrEmpty(newListName)) { _adapter.SetItemName(position, newListName); } _adapter.SetPrice(position, !string.IsNullOrEmpty(inputTextFieldPrice.Text) ? Convert.ToInt32(inputTextFieldPrice.Text) : 0); RunOnUiThread(() => { _adapter.NotifyDataSetChanged(); }); _totalTextView.Text = Convert.ToString(_adapter.GetPriceTotal()); } }); editBox.SetButton2("Cancle", (o, args) => { }); editBox.Show(); optionBox.Cancel(); }
private void ConfigureBusyOverlayAlert() { // Custom UI to show an indicator that route work is in progress. LinearLayout alertLayout = new LinearLayout(this) { Orientation = Orientation.Vertical }; LinearLayout.LayoutParams param = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent, 1.0f ); param.SetMargins(0, 10, 0, 10); TextView processingText = new TextView(this) { Text = "Calculating route...", LayoutParameters = param, Gravity = GravityFlags.Center, }; ProgressBar progressBar = new ProgressBar(this) { Indeterminate = true, LayoutParameters = param, TextAlignment = TextAlignment.Center }; // Add the text and progress bar to the Linear Layout. alertLayout.AddView(processingText); alertLayout.AddView(progressBar); // Create the alert dialog. _busyIndicator = new AlertDialog.Builder(this).Create(); _busyIndicator.SetCanceledOnTouchOutside(false); _busyIndicator.Show(); _busyIndicator.Cancel(); // Add the layout to the alert _busyIndicator.AddContentView(alertLayout, param); }