public override void OnBackPressed() { var builder = new Android.App.AlertDialog.Builder(this); builder.SetTitle ("Exit."); builder.SetIcon (Android.Resource.Drawable.IcDialogAlert); builder.SetMessage("Exit App?"); builder.SetPositiveButton("OK", (s, e) => { System.Environment.Exit(0); }); builder.SetNegativeButton("Cancel", (s, e) => { }); builder.Create().Show(); }
private Task <bool> ShowMessage(string title, string message) { TaskCompletionSource <bool> tcs = new TaskCompletionSource <bool>(); RunOnUiThread(() => { var builder = new Android.App.AlertDialog.Builder(this); builder.SetTitle(title); builder.SetMessage(message); builder.SetNeutralButton("OK", (s, e) => { tcs.SetResult(true); }); var alertDialog = builder.Show(); alertDialog.Show(); }); return(tcs.Task); }
private void BeforeClose() { if (listener.state != State.Joined) { listener.CloseConnection(); Finish(); return; } Android.App.AlertDialog.Builder alert = new Android.App.AlertDialog.Builder(this); alert.SetMessage("Are you sure you want to close the connection?"); alert.SetPositiveButton("Yes", (senderAlert, args) => { listener.CloseConnection(); Finish(); }); alert.Show(); }
protected void AlertBox() { Android.App.AlertDialog.Builder alert = new Android.App.AlertDialog.Builder(this); alert.SetTitle("Confirm Exit"); alert.SetMessage("Do you really want to exit? "); alert.SetPositiveButton("Exit", (senderAlert, args) => { //Toast.MakeText(this, "Deleted!", ToastLength.Short).Show(); Finish1(); }); alert.SetNegativeButton("Cancel", (senderAlert, args) => { Toast.MakeText(this, "Cancelled!", ToastLength.Short).Show(); }); Dialog dialog = alert.Create(); dialog.Show(); }
private void AskForResetConfirmation() { var alertDialog = new Android.App.AlertDialog.Builder(this); alertDialog.SetTitle("Reset"); alertDialog.SetMessage("Are you sure you want to reset the simulation?"); alertDialog.SetCancelable(false); alertDialog.SetPositiveButton("Yes", (s, e) => { Reset(); }); alertDialog.SetNegativeButton("No", (s, e) => { }); alertDialog.Show(); }
public override bool OnOptionsItemSelected(IMenuItem item) { switch (item.ItemId) { case Resource.Id.menu_history_clearHistory: Android.App.AlertDialog.Builder builder = new Android.App.AlertDialog.Builder(this); builder.SetMessage("Are you sure you want to clear receive history?") .SetPositiveButton("Yes", ClearHistoryDialogClickListener) .SetNegativeButton("No", (IDialogInterfaceOnClickListener)null) .Show(); return(true); default: return(base.OnOptionsItemSelected(item)); } }
private void ItemLongClicked(object sender, AdapterView.ItemLongClickEventArgs args) { var contact = contacts[args.Position]; var alert = new Android.App.AlertDialog.Builder(this).Create(); alert.SetTitle("Delete contact"); alert.SetMessage(string.Format("Are you sure you want to delete {0}?", contact.Name)); alert.SetButton("Yes", delegate { contacts.Remove(contact); adapter.NotifyDataSetChanged(); }); alert.SetButton2("No", delegate { }); alert.Show(); }
public void dialodTransacaoNegadaMsitef(Intent data) { Android.App.AlertDialog alertDialog = new Android.App.AlertDialog.Builder(MainActivity.mContext).Create(); StringBuilder cupom = new StringBuilder(); cupom.Append("CODRESP: " + data.GetStringExtra("CODRESP") + "\n"); alertDialog.SetTitle("Ocorreu um erro durante a realização da ação"); alertDialog.SetMessage(cupom.ToString()); alertDialog.SetButton("OK", delegate { alertDialog.Dismiss(); }); alertDialog.Show(); }
public void ShowPermissionRationale(int requestCode, string[] permissions) { var alertBuilder = new Android.App.AlertDialog.Builder(this); alertBuilder.SetCancelable(true); alertBuilder.SetTitle(Resource.String.permission_rationale_title); alertBuilder.SetMessage(GetString(Resource.String.permission_rationale_text) + string.Join(",", permissions)); alertBuilder.SetPositiveButton(Android.Resource.String.Yes, new EventHandler <DialogClickEventArgs>((sender, eventArgs) => { ArchitectView.PermissionManager.PositiveRationaleResult(requestCode, permissions); })); var alert = alertBuilder.Create(); alert.Show(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.registration); EditText name = FindViewById <EditText>(Resource.Id.usernameID); EditText email = FindViewById <EditText>(Resource.Id.EmailID); EditText password = FindViewById <EditText>(Resource.Id.PasswordID); dbhelper = new DBHelper(this); // Create your application here Android.App.AlertDialog.Builder alert = new Android.App.AlertDialog.Builder(this); alert.SetTitle("Error"); alert.SetMessage("Please enter the value"); alert.SetPositiveButton("OK", (senderAlert, args) => { Toast.MakeText(this, "Please Enter a Valid!Value", ToastLength.Short).Show(); }); Dialog dialog = alert.Create(); Button register = FindViewById <Button>(Resource.Id.submit); register.Click += delegate { if (name.Text == "" || email.Text == "" || password.Text == "") { dialog.Show(); } else { dbhelper.insertValue(name.Text, email.Text, password.Text); Android.App.AlertDialog.Builder alert2 = new Android.App.AlertDialog.Builder(this); alert2.SetTitle("Success"); alert2.SetMessage("Registered Successfully!"); alert2.SetPositiveButton("OK", (senderAlert, args) => { StartActivity(typeof(MainActivity)); }); alert2.Create(); alert2.Show(); } }; }
private void OnListItemLongClick(object sender, AdapterView.ItemLongClickEventArgs e) { Log.Debug(TAG, nameof(OnListItemLongClick)); var item = listData.ElementAt(e.Position); Android.App.AlertDialog.Builder builder = new Android.App.AlertDialog.Builder(this.Activity); builder.SetMessage(item.ToString()) .SetPositiveButton(this.Activity.Resources.GetString(Resource.String.Edit), (s, args) => { // DialogFragment.show() will take care of adding the fragment // in a transaction. We also want to remove any currently showing // dialog, so make our own transaction and take care of that here. FragmentTransaction ft = FragmentManager.BeginTransaction(); Fragment prev = FragmentManager.FindFragmentByTag("dialog"); if (prev != null) { ft.Remove(prev); } ft.AddToBackStack(null); Log.Debug(TAG, $"{nameof(OnListItemLongClick)} - try to show ReportFragment like dialog - START"); // Create and show the dialog. DialogFragment newFragment = RecurringPaymentFragment.NewInstance(item.IncludeObjects(db), delegate() { var r = LoadData(); }); newFragment.Show(ft, "dialog"); Log.Debug(TAG, $"{nameof(OnListItemLongClick)} - try to show ReportFragment like dialog - END"); }) .SetNegativeButton(this.Activity.Resources.GetString(Resource.String.Delete), (s, args) => { if (db.Delete(item).Result) { Toast.MakeText(this.Activity, Resources.GetString(Resource.String.Deleted), ToastLength.Short).Show(); var r = LoadData(); } else { Toast.MakeText(this.Activity, Resources.GetString(Resource.String.WasntDeleted), ToastLength.Short).Show(); } }) .Show(); }
private async void MakeLock(bool checkBox) { try { using (var client = ClientHelper.GetClient(CrossSettings.Current.GetValueOrDefault("token", ""))) { ManageOrderService.InitializeClient(client); var o_data = new ServiceResponseObject <SuccessResponse>(); o_data = await ManageOrderService.LockRollete(StaticOrder.Order_id); if (o_data.Status == HttpStatusCode.OK) { Android.App.AlertDialog.Builder alert1 = new Android.App.AlertDialog.Builder(Activity); alert1.SetTitle("Закрытие контейнера"); alert1.SetMessage(o_data.Message); alert1.SetPositiveButton("Закрыть", (senderAlert1, args1) => { }); Dialog dialog1 = alert1.Create(); dialog1.Show(); if (checkBox == true) { //btn_Lock.Clickable = false; //btn_Lock.Focusable = false; //btn_Lock.LongClickable = false; btn_Lock.Visibility = ViewStates.Gone; Lock.Text = "Опущена"; } else { btn_Lock.Text = "Поднять"; Lock.Text = "Опущена"; } //FragmentTransaction transaction1 = this.FragmentManager.BeginTransaction(); //ManageOrderActivity content2 = new ManageOrderActivity(); //transaction1.Replace(Resource.Id.framelayout, content2); //transaction1.Commit(); } } } catch (System.Exception ex) { Toast.MakeText(Activity, ex.Message, ToastLength.Long).Show(); } }
private void Delete_Clicked(object sender, EventArgs e, Activity currentActivity) { btn_delete.Click -= (sndr, argus) => Delete_Clicked(sndr, argus, currentActivity); try { currentActivity.RunOnUiThread(() => { Android.App.AlertDialog.Builder alertDiag = new Android.App.AlertDialog.Builder(currentActivity); alertDiag.SetTitle(Resource.String.DialogHeaderGeneric); alertDiag.SetMessage("Are you sure you want to delete this activity?"); alertDiag.SetIcon(Resource.Drawable.alert); alertDiag.SetPositiveButton(Resource.String.DialogButtonOk, (senderAlert, args) => { ProgressDialog progressDialog = null; progressDialog = ProgressDialog.Show(this.Activity, "Please wait...", "Deleting current activity...", true); new Thread(new ThreadStart(delegate { currentActivity.RunOnUiThread(() => this.DeleteData(progressDialog, currentActivity)); })).Start(); }); alertDiag.SetNegativeButton(Resource.String.DialogButtonNo, (senderAlert, args) => { //btn_save.Click += (sndr, argus) => Save_Clicked(sndr, argus, currentActivity); }); Dialog diag = alertDiag.Create(); diag.Show(); diag.SetCanceledOnTouchOutside(false); }); } catch (Exception ex) { currentActivity.RunOnUiThread(() => { Android.App.AlertDialog.Builder alertDiag = new Android.App.AlertDialog.Builder(currentActivity); alertDiag.SetTitle(Resource.String.DialogHeaderError); alertDiag.SetMessage(ex.Message); alertDiag.SetIcon(Resource.Drawable.alert); alertDiag.SetPositiveButton(Resource.String.DialogButtonOk, (senderAlert, args) => { //btn_save.Click += (sndr, argus) => Save_Clicked(sndr, argus, currentActivity); }); Dialog diag = alertDiag.Create(); diag.Show(); diag.SetCanceledOnTouchOutside(false); }); } }
public async void ShowInvites() { var token = prefs.GetString("token", null); if (token != null && (Activity as AddActivity).CheckConnection()) { try { progressBar.Visibility = ViewStates.Visible; contentLayout.Visibility = ViewStates.Gone; var invites = await _manager.GetUserInvites(token); if (invites != null) { groupsList.Groups = invites; invitesAdapter.NotifyDataSetChanged(); } } catch (UnauthorizedAccessException) { var dialog = new Android.App.AlertDialog.Builder(Context); string message = "Ваши параметры авторизации устарели." + "\nВы будете возвращены на страницу авторизации, чтобы пройти процедуру авторизации заново"; dialog.SetMessage(message); dialog.SetCancelable(false); dialog.SetPositiveButton("Ок", delegate { (Activity as AddActivity).Finish(); }); dialog.Show(); } catch (Exception ex) { var dialog = new Android.App.AlertDialog.Builder(Context); string message = ex.Message; dialog.SetMessage(message); dialog.SetPositiveButton("Ок", delegate { }); dialog.Show(); } finally { progressBar.Visibility = ViewStates.Gone; contentLayout.Visibility = ViewStates.Visible; swiperefresh.Refreshing = false; } } }
private void AgainPrint() { var alertDialog = new Android.App.AlertDialog.Builder(this); alertDialog.SetTitle("Print"); alertDialog.SetMessage("Do you want to print ?"); alertDialog.SetCancelable(false); alertDialog.SetPositiveButton(ConstantValues.YES, (ss, se) => { Print(); }); alertDialog.SetNegativeButton(ConstantValues.NO, (s, e) => { NavigateToMainActivity(); }); alertDialog.Show(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.activity_main); EditText phoneNumberText = FindViewById <EditText>(Resource.Id.PhoneNumberText); //전화걸기 버튼 Button callButton = FindViewById <Button>(Resource.Id.CallButton); callButton.Enabled = false; phoneNumberText.TextChanged += (object sender, TextChangedEventArgs e) => { if (!string.IsNullOrWhiteSpace(phoneNumberText.Text)) { callButton.Enabled = true; } else { callButton.Enabled = false; } }; callButton.Click += (object sender, EventArgs e) => { //Make a Call 버튼 클릭시 전화를 건다. var callDialog = new Android.App.AlertDialog.Builder(this); callDialog.SetMessage("Call " + phoneNumberText.Text + "?"); //"Call"을 클릭하는 경우 // 전화걸기 위한 인텐트 생성 callDialog.SetNeutralButton("Call", delegate { // 인텐트는 액티비티의 전환이 일어날 때 호출하거나 메시지를 전달하는 매개체 // 암시적 인텐트 : 전환될 곳을 직접 지정하지 않고 액션을 적어서 사용한다. // 명시적 인텐트 : 전환될 액티비티를 직접 적어서 표현하는 방법을 사용한다. var callIntent = new Intent(Intent.ActionCall); callIntent.SetData(Android.Net.Uri.Parse("tel:" + phoneNumberText.Text)); StartActivity(callIntent); }); //Cancel을 클릭하는 경우 callDialog.SetNegativeButton("Cancel", delegate { }); callDialog.Show(); }; }
private void LoadData() { var messageDialog = new Android.App.AlertDialog.Builder(this); try { listRutina = db.SelectTableRutina(); var adapter = new ListViewAdapter(this, listRutina); listData.Adapter = adapter; } catch (Exception ex) { messageDialog.SetMessage("Error: " + ex); messageDialog.SetNeutralButton("Try again later", delegate { }); messageDialog.Show(); } }
public void DisplayXFerFailure() { Button btnTransfer = FindViewById <Button>(Resource.Id.btnxFerData); var builder = new Android.App.AlertDialog.Builder(this); builder.SetTitle("Transfer FAILED!"); builder.SetIcon(Resource.Drawable.iconWarning24); builder.SetMessage("Data transfer failed: " + resultxFer); builder.SetPositiveButton("OK", (s, e2) => { } ); builder.Create().Show(); btnTransfer.Enabled = true; }
public bool ShowOkCancelMessage(string title, string message, Action onOk, Action onCancel, bool showNegativeButton = true) { bool result = false; Android.App.AlertDialog.Builder alert = new Android.App.AlertDialog.Builder(Activity); alert.SetTitle(title); alert.SetMessage(message); alert.SetPositiveButton("Ok", (senderAlert, args) => onOk?.Invoke()); if (showNegativeButton) { alert.SetNegativeButton("Cancel", (senderAlert, args) => onCancel?.Invoke()); } Dialog dialog = alert.Create(); dialog.Show(); return(result); }
public void RentEquipmentAlert() { Android.App.AlertDialog.Builder dialog2 = new Android.App.AlertDialog.Builder(this, Android.App.AlertDialog.ThemeHoloLight); dialog2.SetTitle("Do you want to save a equipment?"); dialog2.SetMessage("Save a equipment."); dialog2.SetCancelable(false); dialog2.SetPositiveButton("Yes", delegate { string text = Intent.GetStringExtra("user") ?? "Data not available"; SaveEquipment(); Intent active = new Intent(this, typeof(ActiveRentsActivity)); active.PutExtra("user", text); active.PutExtra("rentid", (int)rentId); StartActivity(active); }); dialog2.SetNegativeButton("Cancel", delegate { return; }); dialog2.Show(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Create your application here SetContentView(Resource.Layout.activity_signup); alert = new Android.App.AlertDialog.Builder(this); myDB = new DBHelperClass(this); userName = FindViewById <EditText>(Resource.Id.inputName); userEmail = FindViewById <EditText>(Resource.Id.inputEmail); userPassword = FindViewById <EditText>(Resource.Id.inputPassword); userAge = FindViewById <EditText>(Resource.Id.inputAge); btn_submit = FindViewById <Button>(Resource.Id.btnSignUp); btn_submit.Click += delegate { var nameValue = userName.Text; var emailValue = userEmail.Text; var passwordValue = userPassword.Text; var ageValue = userAge.Text; if ((nameValue.Trim().Equals("") || nameValue.Length < 0) || (emailValue.Trim().Equals("") || emailValue.Length < 0) || (passwordValue.Trim().Equals("") || passwordValue.Length < 0) || (ageValue.Trim().Equals("") || ageValue.Length < 0)) { alert.SetTitle("Error"); alert.SetMessage("Enter right values in all fields."); alert.SetPositiveButton("OK", AlertOKButton); alert.SetNegativeButton("Cancel", AlertOKButton); Dialog myDialog = alert.Create(); myDialog.Show(); } else { myDB.insertValue(nameValue, emailValue, passwordValue, Convert.ToInt32(ageValue)); Console.WriteLine("Insertion Success"); Intent newScreen = new Intent(this, typeof(LogInActivity)); StartActivity(newScreen); } }; }
protected void Cancel_Selection(object sender, EventArgs e, Activity currentActivity) { try { btn_cancel_plot.Click -= (sndr, argus) => Cancel_Selection(sndr, argus, currentActivity); currentActivity.RunOnUiThread(() => { Android.App.AlertDialog.Builder alertDiag = new Android.App.AlertDialog.Builder(currentActivity); alertDiag.SetTitle(Resource.String.DialogHeaderGeneric); alertDiag.SetMessage(Resource.String.cancelFromAddItemMessage); alertDiag.SetIcon(Resource.Drawable.alert); alertDiag.SetPositiveButton(Resource.String.DialogButtonYes, (senderAlert, args) => { MyFarmDashboardFragment objFragment = new MyFarmDashboardFragment(); Android.Support.V4.App.FragmentTransaction tx = FragmentManager.BeginTransaction(); tx.Replace(Resource.Id.m_main, objFragment, Constants.myfarmdash); tx.Commit(); }); alertDiag.SetNegativeButton(Resource.String.DialogButtonNo, (senderAlert, args) => { //btn_cancel_plot.Click += (sndr, argus) => Cancel_Selection(sndr, argus, currentActivity); }); Dialog diag = alertDiag.Create(); diag.Show(); diag.SetCanceledOnTouchOutside(false); }); } catch (Exception ex) { currentActivity.RunOnUiThread(() => { Android.App.AlertDialog.Builder alertDiag = new Android.App.AlertDialog.Builder(currentActivity); alertDiag.SetTitle(Resource.String.DialogHeaderError); alertDiag.SetMessage(ex.Message); alertDiag.SetIcon(Resource.Drawable.alert); alertDiag.SetPositiveButton(Resource.String.DialogButtonOk, (senderAlert, args) => { //btn_cancel_plot.Click += (sndr, argus) => Cancel_Selection(sndr, argus, currentActivity); }); Dialog diag = alertDiag.Create(); diag.Show(); diag.SetCanceledOnTouchOutside(false); }); } }
public static void ShowMsgWOK(Activity activity, string Title, string MessageText, IconType iconType) { int icon = Resource.Drawable.iconInfo64; switch (iconType) { case IconType.Information: { icon = Resource.Drawable.iconInfo64; break; } case IconType.Checked: { icon = Resource.Drawable.iconCheck64; break; } case IconType.Exclamation: { icon = Resource.Drawable.iconWarning64; break; } case IconType.Critical: { icon = Resource.Drawable.iconBang64; break; } } var builder = new Android.App.AlertDialog.Builder(activity); if (Title != "") { builder.SetTitle(Title); } builder.SetIcon(icon); builder.SetMessage(MessageText); builder.SetPositiveButton("OK", (s, e2) => { } ); builder.Create().Show(); }
private void CreateButton_Click(object sender, EventArgs e) { var newGroupName = groupNameTxt.Text; if (groups.Exists(g => g.ToLower() == newGroupName.ToLower())) { var dialog = new Android.App.AlertDialog.Builder(Context); string message = "Группа с таким названием уже существует"; dialog.SetMessage(message); dialog.SetPositiveButton("Ок", delegate { groupNameTxt.Text = string.Empty; }); dialog.Show(); } else { CreateGroup(newGroupName); } }
private async void SignIn_Click(object sender, System.EventArgs e) { bool isReady = true; EditText usernameField = FindViewById <EditText>(Resource.Id.login_username); EditText passwordField = FindViewById <EditText>(Resource.Id.login_password); // Hide Keyboard when SignIn button is clicked InputMethodManager imm = (InputMethodManager)GetSystemService(Context.InputMethodService); imm.HideSoftInputFromWindow(passwordField.WindowToken, 0); if (usernameField.Text.Length > 0 && passwordField.Text.Length > 0) { string username = usernameField.Text; string password = passwordField.Text; circle.Visibility = Android.Views.ViewStates.Visible; if (await Authentication.Authenticate(username, password)) { Intent intent = new Intent(this, typeof(WelcomeScreen)); StartActivity(intent); } else { alertDialog = new Android.App.AlertDialog.Builder(this.ApplicationContext); alertDialog.SetMessage(GetString(Resource.String.Login_Authentication_Error)); alertDialog.SetNeutralButton("Tęsti", delegate { alertDialog.Dispose(); }); alertDialog.Show(); circle.Visibility = ViewStates.Visible; } } else { alertDialog = new Android.App.AlertDialog.Builder(this); alertDialog.SetMessage(GetString(Resource.String.Login_Empty_Fields_Error)); alertDialog.SetNeutralButton(GetString(Resource.String.Continue_work), delegate { alertDialog.Dispose(); }); alertDialog.Show(); } }
private void Registrar_Click(object sender, System.EventArgs e) { try { CuentaAzure = CloudStorageAccount.Parse("DefaultEndpointsProtocol=https;AccountName=sipsoftalmacenamiento;" + "AccountKey=kCsgLy0KJq/mAnmkPL/wo8squtKGPiGM/eFzX45EpocRQn0LoEygUsl1NB/zM5KaZBo5mu+4bzm2APQezjDeSw=="); tableClient = CuentaAzure.CreateCloudTableClient(); table = tableClient.GetTableReference("Cliente"); table.CreateIfNotExistsAsync(); ClienteEntity cliente = new ClienteEntity(); cliente.Contratados = int.Parse(Contratados.Text); cliente.Emitidos = int.Parse(Emitidos.Text); cliente.Cancelados = int.Parse(Cancelados.Text); cliente.Disponibles = int.Parse(Disponibles.Text); cliente.Total = "$5,664,56"; cliente.UltimaFactura = UltimaFactura.Text; cliente.Nombre = Nombre.Text; cliente.Rfc = "MASJ7834TGHE6"; cliente.Image = "Prueba"; TableOperation insertar = TableOperation.Insert(cliente); table.ExecuteAsync(insertar); Android.App.AlertDialog.Builder builder = new Android.App.AlertDialog.Builder(view.Context); builder.SetMessage("Datos Guardados!"); builder.SetTitle("Aviso"); builder.Create().Show(); //Android.Widget.Toast.MakeText(view.Context, "Se inserto el cliente!", Android.Widget.ToastLength.Short).Show(); } catch (System.Exception ex) { Android.App.AlertDialog.Builder builder = new Android.App.AlertDialog.Builder(view.Context); builder.SetMessage(ex.ToString()); builder.SetTitle("Error"); builder.Create().Show(); //Android.Widget.Toast.MakeText(view.Context, ex.ToString(), Android.Widget.ToastLength.Short).Show(); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_main); Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); Android.App.AlertDialog.Builder dialog = new Android.App.AlertDialog.Builder(this); dialog.SetTitle("AVISO!"); dialog.SetMessage("Esta aplicación hará uso de servicios como \"Teléfono\", \"Cámará\" y \"Localización\" para conocer el estado actual del teléfono. Es necesario que autorices el uso de estos servicios cuando el dispositivo lo solicite.\n Se enviará un correo por cada aviso de arribo o \"Check-in\" a tus supervisores directos. Favor de utilizarla con moderación."); dialog.SetIcon(Resource.Drawable.baseline_warning_24); dialog.SetNeutralButton("Entendido", NeutralAction); dialog.Show(); fab = FindViewById <FloatingActionButton>(Resource.Id.fab); t = FindViewById <TextInputEditText>(Resource.Id.textInputEditText1); cameraView = FindViewById <ImageView>(Resource.Id.cameraImageView); takePic = FindViewById <FloatingActionButton>(Resource.Id.takePic); linearLayout = FindViewById <LinearLayout>(Resource.Id.linearLayout1); title = FindViewById <TextView>(Resource.Id.homeTitle); //mDrawer = FindViewById<DrawerLayout>(Resource.Id.drawer_layout); takePic.Tag = photoTag; InitializeLocationManager(); mTelephonyMgr = (TelephonyManager)GetSystemService(TelephonyService); if (!(ContextCompat.CheckSelfPermission(this, Manifest.Permission.ReadPhoneState) == (int)Permission.Granted)) { // permission is not granted. If necessary display rationale & request. RequestPhonePermission(); } title.SetTypeface(Typeface.CreateFromAsset(Assets, "Product Sans Regular.ttf"), TypefaceStyle.Bold); t.SetTypeface(Typeface.CreateFromAsset(Assets, "Product Sans Regular.ttf"), TypefaceStyle.Normal); fab.Visibility = ViewStates.Invisible; fab.Click += FabOnClick; takePic.Click += TakeAPicture; }
public void OpenRoom(Object sender, EventArgs e) { ISharedPreferences preferences = PreferenceManager.GetDefaultSharedPreferences(Context); String username = preferences.GetString("username", ""); if (username.Length < 4 || username.Length > 20) { Android.App.AlertDialog.Builder alert = new Android.App.AlertDialog.Builder(Context); alert.SetTitle("Username not valid"); alert.SetMessage("Username must be around 4 and 20 characters."); alert.SetPositiveButton("Change it", (senderAlert, args) => { Intent intent = new Intent(Context, typeof(SettingsActivity)); Context.StartActivity(intent); }); alert.Show(); return; } Intent i = new Intent(Context, typeof(RoomActivity)); i.PutExtra("address", room.address); i.PutExtra("port", room.port); i.PutExtra("username", username); if (room.hasPassword) { EditText input = new EditText(Context); input.Hint = "Password"; input.Text = preferences.GetString("default_password", ""); input.InputType = Android.Text.InputTypes.TextVariationPassword | Android.Text.InputTypes.ClassText; Android.App.AlertDialog.Builder alert = new Android.App.AlertDialog.Builder(Context); alert.SetTitle("Insert password"); alert.SetView(input); alert.SetPositiveButton("Join Room", (senderAlert, args) => { i.PutExtra("password", input.Text); Context.StartActivity(i); }); alert.Show(); } else { i.PutExtra("password", ""); Context.StartActivity(i); } }
/*private void Menu_MenuItemClick(object sender, PopupMenu.MenuItemClickEventArgs e, Activity currentActivity, PopupMenu m) * { * try * { * switch (e.Item.ItemId) * { * case Resource.Id.m_OpenCamera: * CameraOpen(); * break; * case Resource.Id.m_OpenGallery: * GalleryOpen(); * break; * default: * break; * } * } * catch (Exception ex) * { * currentActivity.RunOnUiThread(() => * { * Android.App.AlertDialog.Builder alertDiag = new Android.App.AlertDialog.Builder(currentActivity); * alertDiag.SetTitle(Resource.String.DialogHeaderError); * alertDiag.SetMessage(ex.Message); * alertDiag.SetIcon(Resource.Drawable.alert); * alertDiag.SetPositiveButton(Resource.String.DialogButtonOk, (senderAlert, args) => * { * //btn_show_popup.Click += (sndr, argus) => Camera_Clicked(sndr, argus, currentActivity, btn); * }); * Dialog diag = alertDiag.Create(); * diag.Show(); * diag.SetCanceledOnTouchOutside(false); * }); * } * finally * { * m.Dismiss(); * } * }*/ public override void OnActivityResult(int requestCode, int resultCode, Intent data) { try { if (requestCode == 0 && resultCode == (int)Result.Ok) { CropImage(this.Activity); } else if (requestCode == 2) { if (data != null) { CropImage(this.Activity, data.Data); } } else if (requestCode == 1) { if (data != null && data.Data != null) { using (Android.Graphics.Bitmap bitmap = data.Data.Path.LoadAndResizeBitmap(Resources.DisplayMetrics.WidthPixels, img_product_view.Height)) { img_product_view.RecycleBitmap(); img_product_view.SetImageBitmap(bitmap); gotFile = true; } } } } catch (Exception ex) { this.Activity.RunOnUiThread(() => { Android.App.AlertDialog.Builder alertDiag = new Android.App.AlertDialog.Builder(this.Activity); alertDiag.SetTitle(Resource.String.DialogHeaderError); alertDiag.SetMessage(ex.Message); alertDiag.SetIcon(Resource.Drawable.alert); alertDiag.SetPositiveButton(Resource.String.DialogButtonOk, (senderAlert, args) => { }); Dialog diag = alertDiag.Create(); diag.Show(); diag.SetCanceledOnTouchOutside(false); }); } }
//save restaurant if user is logged in, if not prompt login void saveButtonClick(object sender, EventArgs e) { ISharedPreferences prefs = Application.Context.GetSharedPreferences("UserInfo", FileCreationMode.Private); string userID = prefs.GetString("userID", null); if (saveButton.Selected == true) { saveButton.Selected = false; if (userID == null) { //Toast.MakeText(this, "User Not Logged In", ToastLength.Short).Show(); Console.WriteLine("User not logged in"); } else { deleteSavedRestaurant(userID); } } else { //prompy user to login then take them to login page if (userID == null) { Android.App.AlertDialog.Builder alert = new Android.App.AlertDialog.Builder(this); alert.SetTitle("Log In"); alert.SetMessage("You need to log in to add restaurants to favourites"); alert.SetPositiveButton("Log In", (senderAlert, args) => { Intent intent = new Intent(this, typeof(LogInActivity)); intent.PutExtra("RestaurantInfo", Intent.GetStringExtra("RestaurantInfo")); StartActivity(intent); Finish(); }); alert.SetNegativeButton("Cancel", (senderAlert, args) => { }); Dialog dialog = alert.Create(); dialog.Show(); } else { saveButton.Selected = true; saveRestaurant(userID); } } }
private void SeachProducts(string query, string offset) { //Clear adapter FirebaseDatabase database = FirebaseDatabase.Instance; FirebaseCallback p = new FirebaseCallback(); p.SearchProducts(query.ToLower(), Category, SubCategory, offset, database); p.GetProduct += (sender, obj) => { if (obj.Count > 0) { if (Adapter != null && Adapter.Product.Count > 0) { Adapter.AddList(obj); } else { Adapter = new Product_Adapter(this, obj, this); recyclerView.SetAdapter(Adapter); } onScrollListener.IsLoading = false; HideShowProgress(); SearchOffset = obj[obj.Count - 1].sort_name; } else if (Adapter.Product.Count == 0) { onScrollListener.IsLoading = false; HideShowProgress(); var builder = new Android.App.AlertDialog.Builder(this); builder.SetTitle(Resource.String.dlg_info); builder.SetMessage(Resource.String.info_nomatch_result); builder.SetPositiveButton(Resource.String.dialog_ok, delegate { builder.Dispose(); }); builder.Show(); } else { onScrollListener.IsLoading = false; HideShowProgress(); } LastLoad = obj.Count; }; }
public override void DisplayMessage(MessageDisplayParams messageParams) { Android.App.AlertDialog.Builder builder = new Android.App.AlertDialog.Builder(this.context); builder.SetTitle(messageParams.Title); builder.SetMessage(messageParams.Message); if (messageParams.PositiveAction != null) { builder.SetPositiveButton(messageParams.PositiveLabel ?? DefaultPositiveLabel, (s, e) => { messageParams.PositiveAction(); }); } if (messageParams.NegativeAction != null) { builder.SetNegativeButton(messageParams.NegativeLabel ?? DefaultNegativeLabel, (s, e) => { messageParams.NegativeAction(); }); } if (messageParams.NeutralAction != null) { builder.SetNeutralButton(messageParams.NeutralLabel ?? string.Empty, (s, e) => { messageParams.NeutralAction(); }); } var dialog = builder.Create(); dialog.DismissEvent += (sender, e) => { this.messages.Remove(messageParams); }; this.messages.Add(messageParams); this.dialogs.Add(dialog); dialog.Show(); }
private void DeleteFolderOrFile (string path) { popupWindow.Dismiss (); var alertDialogConfirmDelete = new Android.App.AlertDialog.Builder (Activity); alertDialogConfirmDelete.SetTitle("Waarschuwing"); alertDialogConfirmDelete.SetMessage("Bent u zeker van deze verwijder actie? \nDeze actie is niet terug te draaien."); alertDialogConfirmDelete.SetPositiveButton ("Verwijderen", async delegate { try { parentActivity.ShowProgressDialog ("Verwijderen... Een ogenblik geduld a.u.b."); bool deleteSucceed = await DataLayer.Instance.DeleteFileOrFolder (path); parentActivity.HideProgressDialog (); if (!deleteSucceed) { Toast.MakeText (Android.App.Application.Context, "Verwijderen mislukt - druk op ververs en probeer het a.u.b. opnieuw", ToastLength.Long).Show (); } else { Toast.MakeText (Android.App.Application.Context, "Verwijderen succesvol", ToastLength.Short).Show (); //Refresh listview RefreshData (); } } catch (Exception ex){ Insights.Report(ex); parentActivity.HideProgressDialog (); Toast.MakeText (Android.App.Application.Context, "Verwijderen mislukt - druk op ververs en probeer het a.u.b. opnieuw", ToastLength.Long).Show (); } }); alertDialogConfirmDelete.SetNegativeButton ("Annuleren", delegate { alertDialogConfirmDelete.Dispose(); }); alertDialogConfirmDelete.Create ().Show (); }
public void btnCloseA_OnClick(object sender, EventArgs EventArgs) { var builder = new Android.App.AlertDialog.Builder(this); builder.SetTitle ("Exit."); builder.SetIcon (Android.Resource.Drawable.IcDialogAlert); builder.SetMessage("Exit App?"); builder.SetPositiveButton("OK", (s, e) => { Finish(); Android.OS.Process.KillProcess(Android.OS.Process.MyPid()); //System.Environment.Exit(0); }); builder.SetNegativeButton("Cancel", (s, e) => { }); builder.Create().Show(); }
private void DialogToShowAccountsOnDevice () { var am = AccountManager.Get (this); // "this" references the current Context var accounts = am.GetAccountsByType ("com.google"); var miaAlert = new Android.App.AlertDialog.Builder (this); if (accounts != null && accounts.Length > 0) { miaAlert.SetTitle ("i found an account name! and total # = " + accounts.Length); miaAlert.SetMessage (accounts [0].Name); } else { miaAlert.SetTitle ("No Account Found"); miaAlert.SetMessage ("None"); } var alert = miaAlert.Create (); alert.Show (); }
void ShowGeocodingErrorAlert() { // as long as this activity is not yet destroyed, show an alert indicating the gecooding error if (!IsDestroyed) { //set alert for executing the task var alert = new Android.App.AlertDialog.Builder(this); alert.SetTitle("Geocoding Error"); alert.SetMessage("An error occurred while converting the street address to GPS coordinates."); alert.SetPositiveButton("OK", (senderAlert, args) => { // an empty delegate body, because we just want to close the dialog and not take any other action }); //run the alert in UI thread to display in the screen RunOnUiThread(() => { alert.Show(); }); } }
private async void OpenFileIn (TreeNode clickedItem) { try { if (popupWindow != null) { popupWindow.Dismiss (); } string mimeTypeOfClickedItem = MimeTypeHelper.GetMimeType (clickedItem.Path); clickedItem.Type = mimeTypeOfClickedItem; if (clickedItem.Type.Equals ("application/pdf")) { Intent intent = new Intent (Intent.ActionView); new Thread (new ThreadStart (async delegate { //Show progress dialog while loading parentActivity.HideProgressDialog (); parentActivity.ShowProgressDialog (null); string fullFilePath = await DataLayer.Instance.GetFilePath (clickedItem.Path); //Controleer internet verbinding var connectivityManager = (ConnectivityManager)Android.App.Application.Context.GetSystemService (Context.ConnectivityService); var activeConnection = connectivityManager.ActiveNetworkInfo; if ((activeConnection != null) && activeConnection.IsConnected) { //Internet verbinding gedetecteerd //Create temp file string temporaryFilePath = System.IO.Path.Combine ("/storage/emulated/0/Download", clickedItem.Name); if (File.Exists (temporaryFilePath)) { File.Delete (temporaryFilePath); } //Save settings of last opened file ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences (Activity); ISharedPreferencesEditor editor = prefs.Edit (); editor.PutString ("fileNameLastOpenedPdf", clickedItem.Name); editor.PutString ("pathLastOpenedPdf", clickedItem.Path); editor.PutString ("temporaryFilePath", temporaryFilePath); editor.PutBoolean ("isFavorite", clickedItem.IsFavorite); editor.Commit (); //Save temporary file in filesystem Byte[] fileBytes = File.ReadAllBytes (fullFilePath); File.WriteAllBytes (temporaryFilePath, fileBytes); Android.Net.Uri uri = Android.Net.Uri.Parse ("file://" + temporaryFilePath); intent.SetDataAndType (uri, clickedItem.Type); parentActivity.HideProgressDialog (); if(File.Exists (temporaryFilePath)){ Activity.StartActivity (intent); } else { Toast.MakeText (Android.App.Application.Context, "Openen bestand mislukt", ToastLength.Long).Show (); } } else { //Geen internet verbinding var alertDialogConfirmDelete = new Android.App.AlertDialog.Builder (Activity); alertDialogConfirmDelete.SetTitle ("Geen verbinding"); alertDialogConfirmDelete.SetMessage ("U heeft momenteel geen internet verbinding. Het maken van PDF annotaties is daarom niet mogelijk."); alertDialogConfirmDelete.SetPositiveButton ("OK", async delegate { Android.Net.Uri uri = Android.Net.Uri.Parse ("file://" + fullFilePath); intent.SetDataAndType (uri, clickedItem.Type); parentActivity.HideProgressDialog (); Activity.StartActivity (intent); }); alertDialogConfirmDelete.Create ().Show (); } })).Start (); } else {//Ander bestandstype dan PDF openen //Show progress dialog while loading parentActivity.HideProgressDialog (); parentActivity.ShowProgressDialog (null); string fullFilePath = await DataLayer.Instance.GetFilePath (clickedItem.Path); Intent intent = new Intent(Intent.ActionView, Android.Net.Uri.Parse (CustomContentProvider.CONTENT_URI + fullFilePath)); intent.SetFlags (ActivityFlags.GrantReadUriPermission); intent.SetFlags (ActivityFlags.NewTask); intent.SetFlags (ActivityFlags.ClearWhenTaskReset); Activity.StartActivity (intent); } } catch (Exception ex){ Insights.Report(ex); Console.WriteLine (ex.Message); parentActivity.HideProgressDialog (); if (ex is ActivityNotFoundException) { Toast.MakeText (Android.App.Application.Context, "Geen app op uw apparaat gevonden om dit bestandstype te kunnen openen", ToastLength.Long).Show (); } else { Toast.MakeText (Android.App.Application.Context, "Openen bestand mislukt", ToastLength.Long).Show (); } } }
public override void OnBackPressed() { var builder = new Android.App.AlertDialog.Builder(this); builder.SetTitle ("Exit."); builder.SetIcon (Android.Resource.Drawable.IcDialogAlert); builder.SetMessage("Exit App?"); builder.SetPositiveButton("OK", (s, e) => { mSharedPreferences = this.GetSharedPreferences ("CheckInPrefs", FileCreationMode.Private); ISharedPreferencesEditor editor = mSharedPreferences.Edit (); editor.Remove ("SessionKey"); editor.Commit (); if (!(geofenceRequestIntent == null)) { geofenceRequestIntent.Cancel (); } Finish(); Android.OS.Process.KillProcess(Android.OS.Process.MyPid()); //System.Environment.Exit(0); }); builder.SetNegativeButton("Cancel", (s, e) => { }); builder.Create().Show(); }
void ListView_OnItemLongClick (object sender, AdapterView.ItemLongClickEventArgs e) { LocalBox clickedItem = foundLocalBoxes [e.Position]; LayoutInflater inflater = (LayoutInflater)Activity.GetSystemService (Context.LayoutInflaterService); View popupView; popupView = inflater.Inflate (Resource.Layout.custom_popup_root, null); PopupWindow popupWindow = new PopupWindow (popupView, e.View.Width, e.View.Height); //Hide popup window when clicking outside its view popupWindow.Focusable = true; popupWindow.Update (); popupWindow.SetBackgroundDrawable(new BitmapDrawable()); popupWindow.ShowAsDropDown (e.View, 0, - e.View.Height); ImageButton buttonDelete = (ImageButton) popupView.FindViewById(Resource.Id.button_popup_root_delete); buttonDelete.Click += delegate { popupWindow.Dismiss(); var alertDialogConfirmDelete = new Android.App.AlertDialog.Builder (Activity); alertDialogConfirmDelete.SetTitle("Waarschuwing"); alertDialogConfirmDelete.SetMessage("Weet u zeker dat u deze Pleiobox wilt verwijderen? \nDeze actie is niet terug te draaien."); alertDialogConfirmDelete.SetPositiveButton ("Verwijderen", async delegate { try{ DataLayer.Instance.DeleteLocalBox(clickedItem.Id); ResetUIToBeginState(true); UpdateLocalBoxes(); List<LocalBox> registeredLocalBoxes = await DataLayer.Instance.GetLocalBoxes (); if (registeredLocalBoxes.Count == 0) { HomeActivity homeActivity = (HomeActivity)Activity; homeActivity.ShowLoginDialog(); } //Reset logo //imageViewLogo.SetImageResource (Resource.Drawable.beeldmerk_belastingdienst); }catch (Exception ex){ Insights.Report(ex); Toast.MakeText (Android.App.Application.Context, "Het verwijderen van de Pleiobox is mislukt", ToastLength.Short).Show (); } }); alertDialogConfirmDelete.SetNegativeButton ("Annuleren", delegate { alertDialogConfirmDelete.Dispose(); }); alertDialogConfirmDelete.Create ().Show (); }; }