Ejemplo n.º 1
1
 void showAlert(AlertDialog.Builder builder)
 {
     alert = builder.Create();
     alert.Show();
     var acceptButton = alert.GetButton((int)DialogButtonType.Positive);
     acceptButton.Click += saveNewDrink;
     var cancelButton = alert.GetButton((int)DialogButtonType.Negative);
     cancelButton.Click += (sender, e) => { alert.Dismiss(); };
 }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            // Create the Dialog object used to display messages
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            ActivityDialog = builder.Create ();
            ActivityDialog.SetTitle("HelloWorld");
            ActivityDialog.DismissEvent += (sender, e) => {
                FindViewById<TextView> (Resource.Id.textViewMessage).Text = "Alert dismissed at " + DateTime.Now.ToLongTimeString();
            };

            // 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 buttonClicker = FindViewById<Button> (Resource.Id.myButton);

            buttonClicker.Click += delegate {
                buttonClicker.Text = string.Format ("{0} clicks!", count++);
            };

            FindViewById<Button> (Resource.Id.buttonPopupMessage).Click += buttonPopupMessage_Click;
        }
Ejemplo n.º 3
0
        private async void OnSmSShare_Click(object sender, EventArgs e)
        {
            String messageText = "Check this item out";
            String recipient   = "02102339008";

            try
            {
                var message = new SmsMessage(messageText, new[] { recipient });
                await Sms.ComposeAsync(message);
            }
            catch (FeatureNotSupportedException ex)
            {
                // Sms is not supported on this device.
                Android.App.AlertDialog.Builder builders = new Android.App.AlertDialog.Builder(this);
                builders.SetMessage("SMS is not supported on this phone ").SetTitle("Feature Not Supported");
                Android.App.AlertDialog dialog = builders.Create();
            }
            catch (Exception ex)
            {
                // Other error has occurred.
            }

            NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID)
                                                 .SetAutoCancel(false)
                                                 .SetSmallIcon(Resource.Drawable.abc_ic_star_black_36dp)
                                                 .SetContentTitle("XamarinApp")
                                                 .SetContentText("You have shared a product");

            var notificationManager = NotificationManagerCompat.From(this);

            notificationManager.Notify(NOTIFICATION_ID, builder.Build());
        }
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            switch (item.ItemId)
            {
            case Android.Resource.Id.Home:
                Android.App.AlertDialog.Builder builder = new Android.App.AlertDialog.Builder(this);
                Android.App.AlertDialog         alert   = builder.Create();
                alert.SetTitle("Cancel warning");
                alert.SetMessage("Are you sure you want to cancel?");

                alert.SetButton2("NO", (c, ev) =>
                {
                    //cancel button
                });

                alert.SetButton("YES", (c, ev) =>
                {
                    Finish();
                });

                alert.Show();
                return(true);

            default:
                return(base.OnOptionsItemSelected(item));
            }
        }
 public void ShowConfirmDelete(string alerTitle, string alertMessage, string id)
 {
     Android.App.AlertDialog.Builder showDialog = new Android.App.AlertDialog.Builder(this);
     Android.App.AlertDialog         Alert      = showDialog.Create();
     Alert.SetTitle(alerTitle);
     Alert.SetMessage(alertMessage);
     Alert.SetButton("YES", delegate
     {
         try
         {
             string URL = "https://download-tracker.herokuapp.com/movies/" + id;
             DeleteMovie(URL);
         }
         catch (Exception e)
         {
             Console.WriteLine(e.Message);
         }
     });
     Alert.SetButton2("NO", delegate
     {
         Alert.Dismiss();
         Alert.Dispose();
         return;
     });
     Alert.Show();
 }
Ejemplo n.º 6
0
        private void btnPost_Click(object sender, EventArgs e)
        {
            Android.App.AlertDialog.Builder dialog = new Android.App.AlertDialog.Builder(mainContext);
            Android.App.AlertDialog         alert  = dialog.Create();
            alert.SetTitle("Confirmation");
            alert.SetMessage("Are you sure you want to upload the selected file?");
            alert.SetButton("OK", async(c, ev) =>
            {
                var array = Helpers.VideoHelper.GetSelectedMediaData((Activity)mainContext, intentData.Data);

                if (tabbed != null)
                {
                    await tabbed.UploadSelectedResponse(array, editDescription.Text);
                }
                else if (global != null)
                {
                    await global.UploadSelectedResponse(array, editDescription.Text);
                }

                alert.Hide();
                this.Dismiss();
            });
            alert.SetButton2("CANCEL", (c, ev) => { alert.Hide(); });
            alert.Show();
        }
Ejemplo n.º 7
0
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            switch (item.ItemId)
            {
            case Resource.Id.close_session:

                // Close session

                Android.App.AlertDialog.Builder dialog = new Android.App.AlertDialog.Builder(this);
                Android.App.AlertDialog         alert  = dialog.Create();
                alert.SetTitle("Aviso");
                alert.SetMessage("¿Seguro que desea cerrar la sesión?");
                alert.SetButton("Si", (c, ev) =>
                {
                    Intent shortDialDetails = new Intent(Application.Context, typeof(LoginActivity));
                    StartActivity(shortDialDetails);
                    Finish();
                });

                alert.SetButton2("Cancelar", (c, ev) => { });

                alert.Show();

                return(true);

            case Resource.Id.filter:
                return(false);
            }

            return(base.OnOptionsItemSelected(item));
        }
Ejemplo n.º 8
0
        /*protected override void OnResume()
         * {
         *  base.OnResume();
         *  locationManager.RequestLocationUpdates(provider, 1, 1, this);
         * }
         *
         * protected override void OnPause()
         * {
         *  base.OnPause();
         *  locationManager.RemoveUpdates(this);
         * }*/
        async void FnProcessOnMap()
        {
            try
            {
                await FnLocationToLatLng();

                FnUpdateCameraPosition(latLngSource);
            }
            catch (Exception e)
            {
                Android.App.AlertDialog.Builder dialog = new Android.App.AlertDialog.Builder(this);
                Android.App.AlertDialog         alert  = dialog.Create();
                alert.SetTitle("No Connection");
                alert.SetMessage("Please turn on the Internet");
                alert.SetButton("OK", (c, ev) =>
                {
                    StartActivity(new Android.Content.Intent(Application.Context, typeof(MainPage)));
                });
                alert.Show();
            }

            if (latLngSource != null && latLngDestination != null)
            {
                FnDrawPath(strSourceLocation, strDestinationLocation);
            }
        }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = inflater.Inflate(Resource.Layout.category_dialog, null);

            Dialog.SetTitle("Выберите категории");
            var mainLayout = view.FindViewById <LinearLayout>(Resource.Id.category_dialog_main);

            _checkBoxList = new List <CheckBox>();

            for (var index = 0; index < ServicesCategory.ServicesCategoryList.Count; index++)
            {
                var check    = ServicesCategory.ServicesCategoryList[index];
                var checkbox = new CheckBox(Context)
                {
                    Text             = check,
                    Checked          = _firstMasterViewModel.SelectedCategories.Exists(s => s.ToLower().Equals(check.ToLower())),
                    LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent,
                                                                     ViewGroup.LayoutParams.WrapContent)
                };
                _checkBoxList.Add(checkbox);
                mainLayout.AddView(checkbox);
            }

            _closeButton        = view.FindViewById <Button>(Resource.Id.category_dialog_closeButton);
            _closeButton.Click += CloseButtonOnClick;

            var builder = new AlertDialog.Builder(Activity);

            builder.SetView(view);

            _createdDialog = builder.Create();
            return(view); // base.OnCreateView(inflater, container, savedInstanceState);
        }
 protected override void InitializeDialogItems(AlertDialog.Builder builder, string[] items)
 {
     if (!keepTempSelectedItems)
         tempSelectedItems = CopyGenericList(SelectedItems);
     var checkedItems = ItemsSource.Cast<object>().Select(item => tempSelectedItems.Contains(item)).ToArray();
     builder.SetMultiChoiceItems(items, checkedItems, Dialog_Click);
 }
Ejemplo n.º 11
0
        private void ShowLogoutDialog()
        {
            builder     = new Android.App.AlertDialog.Builder(mainActivity);
            alertDialog = builder.Create();
            alertDialog.SetMessage("Do you want to log out?");
            alertDialog.SetButton("Yes", (s1, e1) =>
            {
                var auth = sessionManager.GetFirebaseAuth();
                editor   = preferences.Edit();
                LoginManager.Instance.LogOut();
                auth.SignOut();
                editor.Clear();
                editor.Commit();

                var intent = new Intent(Application.Context, typeof(OnboardingActivity));
                intent.SetFlags(ActivityFlags.ClearTask | ActivityFlags.ClearTop | ActivityFlags.NewTask);
                StartActivity(intent);
                mainActivity.Finish();
            });

            alertDialog.SetButton2("No", (s2, e2) =>
            {
                alertDialog.Dismiss();
            });
            alertDialog.Show();
        }
Ejemplo n.º 12
0
        void CallAlert(string title, string cardLinkId = null, bool orderButtonShown = true, bool linkedSuccessfully = false)
        {
            Android.App.AlertDialog.Builder builder = new Android.App.AlertDialog.Builder(this);
            if (cardLinkId != null)
            {
                builder.SetPositiveButton(TranslationHelper.GetString("yes", GetCurrentCulture.GetCurrentCultureInfo()), async(object s, DialogClickEventArgs e) => { await LinkCard(cardLinkId); });
                builder.SetNegativeButton(TranslationHelper.GetString("no", GetCurrentCulture.GetCurrentCultureInfo()), (object s, DialogClickEventArgs e) => { });
            }
            else
            {
                builder.SetPositiveButton("OK", (object s, DialogClickEventArgs e) =>
                {
                    if (linkedSuccessfully)
                    {
                        OnBackPressed();
                    }
                });
                if (orderButtonShown)
                {
                    builder.SetNeutralButton(TranslationHelper.GetString("orderStickerWithQr", GetCurrentCulture.GetCurrentCultureInfo()), (object s, DialogClickEventArgs e) => OpenOrderLink(s, e));
                }
            }

            builder.SetMessage(title);
            Android.App.AlertDialog dialog = builder.Create();
            dialog.Show();
        }
 private async Task RunCountDown()
 {
     if (count > 0)
     {
         count--;
         RunOnUiThread(() => { Countdown.Text = "" + count; });
     }
     else
     {
         Android.App.AlertDialog.Builder dialog = new Android.App.AlertDialog.Builder(this);
         Android.App.AlertDialog         alert  = dialog.Create();
         alert.SetTitle("Failed confirmation");
         alert.SetMessage("Check it again!");
         alert.SetButton("OK", (c, ev) =>
         {
             RunOnUiThread(() =>
             {
                 count = 60;
                 edittext_confirm.Text = "";
                 Countdown.Text        = "" + count;
             });
         });
         alert.Show();
     }
 }
Ejemplo n.º 14
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Options);

            SeekBar speedBar = FindViewById<SeekBar>(Resource.Id.sbSpeed);
            Button btnSave = FindViewById<Button>(Resource.Id.btnOptionsSave);
            TextView txtValue = FindViewById <TextView>(Resource.Id.txtValue);

            int speed = 2000;
            txtValue.Text = "The gamespeed is: 2 seconds per move.";
            alert = new AlertDialog.Builder(this).Create();

            speedBar.Progress = 1;

            speedBar.ProgressChanged += (object sender, SeekBar.ProgressChangedEventArgs e) =>
            {
                if (e.FromUser)
                {
                    txtValue.Text = "The gamespeed is: " + (e.Progress + 1).ToString() + " seconds per move.";
                    speed = e.Progress * 1000 + 1000;
                }
            };

            btnSave.Click += (object sender, EventArgs e) =>
            {
                updateDatabase(speed);
                ShowPopUpMessage("Options saved.");
            };
        }
        private void btnPost_Click(object sender, EventArgs e)
        {
            Android.App.AlertDialog.Builder dialog = new Android.App.AlertDialog.Builder(mainContext);
            Android.App.AlertDialog         alert  = dialog.Create();
            alert.SetTitle("Confirmation");
            alert.SetMessage("Are you sure you want to upload this recording?");
            alert.SetButton("OK", async(c, ev) =>
            {
                await videoRecord.UploadRecordedResponse(editDescription.Text);
                var tabbedActivity = TabbedMainActivity.GetInstance();
                if (tabbedActivity != null)
                {
                    int UnseenResponseCount = API.UserResponseAPI.GetUnseenResponseNotification();
                    if (UnseenResponseCount > 0)
                    {
                        tabbedActivity.MyChannelFragment.UnSeenReponse = UnseenResponseCount;
                        tabbedActivity.FragmentBottomNavigator.txtUnSeenCount.Visibility = ViewStates.Visible;
                        tabbedActivity.FragmentBottomNavigator.txtUnSeenCount.Text       = UnseenResponseCount.ToString();
                    }
                    else
                    {
                        tabbedActivity.FragmentBottomNavigator.txtUnSeenCount.Visibility = ViewStates.Gone;
                    }
                }

                alert.Hide();
                this.Dismiss();
            });
            alert.SetButton2("CANCEL", (c, ev) => { alert.Hide(); });
            alert.Show();
        }
Ejemplo n.º 16
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_doc_scan_ui_main);

            SupportActionBar.SetHomeButtonEnabled(true);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);

            CurrentActivity = this;
            imageListView   = FindViewById <ListView>(Resource.Id.list);

            btScan        = FindViewById <Button>(Resource.Id.btScan);
            btScan.Click += (sender, e) =>
            {
                // if "scan document" is called repeatedly the user will be warned that scan results from the previous pass will get lost:
                if (FullImagePath != null &&
                    FullImagePath.Length > 0)
                {
                    Android.App.AlertDialog.Builder builder = new Android.App.AlertDialog.Builder(this);
                    builder.SetTitle("Confirm");
                    builder.SetMessage("If you perform new scans existing scans will be overwritten");

                    builder.SetPositiveButton("Ok", (senderAlert, args) => {
                        callDocumentScanViewUIActivity();
                    });

                    Android.App.AlertDialog alert = builder.Create();
                    alert.Show();
                }
                else
                {
                    callDocumentScanViewUIActivity();
                }
            };
        }
        private void CreateLayout()
        {
            // Create the layout.
            LinearLayout layout = new LinearLayout(this)
            {
                Orientation = Orientation.Vertical
            };

            // Add the generate button.
            _takeMapOfflineButton = new Button(this)
            {
                Text = "Take map offline"
            };
            _takeMapOfflineButton.Click += TakeMapOfflineButton_Click;
            layout.AddView(_takeMapOfflineButton);

            // Add the mapview.
            _mapView = new MapView(this);
            layout.AddView(_mapView);

            // Add the layout to the view.
            SetContentView(layout);

            // Create the progress dialog display.
            _progressIndicator = new ProgressBar(this);
            _progressIndicator.SetProgress(40, true);
            AlertDialog.Builder builder = new AlertDialog.Builder(this).SetView(_progressIndicator);
            builder.SetCancelable(true);
            builder.SetMessage("Generating offline map ...");
            _alertDialog = builder.Create();
            _alertDialog.SetButton("Cancel", (s, e) => { _generateOfflineMapJob.Cancel(); });
        }
Ejemplo n.º 18
0
 //Al dar click en la foto
 private void perfil_Click(object sender, EventArgs e)
 {
     Android.App.AlertDialog.Builder builder    = new Android.App.AlertDialog.Builder(this);
     Android.App.AlertDialog         alerDialog = builder.Create();
     //Titulo
     alerDialog.SetTitle("PERFIL");
     //Icono
     alerDialog.SetIcon(Resource.Drawable.Perfil);
     //Pregunta
     alerDialog.SetMessage("¿Desea cambiar la foto de Perfil?");
     alerDialog.SetButton("No", (s, ev) =>
     {
         StartActivity(typeof(VerPerfil));
     });
     alerDialog.SetButton3("Si", (s, ev) =>
     {
         try
         {
             Intent intent = new Intent(MediaStore.ActionImageCapture);
             StartActivityForResult(intent, 0);
         }
         catch (Exception ex)
         {
         }
     });
     alerDialog.Show();
 }
        private void BtnApply_Click(object sender, EventArgs e)
        {
            lvRevenueOffice.Adapter = new RevenueAdapter(this, new List <Revenue> ());

            Android.App.AlertDialog.Builder dialog = new Android.App.AlertDialog.Builder(this);
            Android.App.AlertDialog         alert  = dialog.Create();

            if (tvDate.Text == "Select Date")
            {
                alert.SetTitle("Message");
                alert.SetMessage("Please choose date before apply");
                alert.SetButton("OK", (c, ev) =>
                {
                });
                alert.Show();
                return;
            }

            if (DateTime.Parse(tvDate.Text).Date >= new DateTime(2019, 4, 1))
            {
                alert.SetTitle("Message");
                alert.SetMessage("No data");
                alert.SetButton("OK", (c, ev) =>
                {
                });
                alert.Show();
                return;
            }

            LoadRevenueOffice();
        }
Ejemplo n.º 20
0
        private void Propinabtn_Click(object sender, EventArgs e)
        {
            LayoutInflater layoutInflater = LayoutInflater.From(this);
            View           view           = layoutInflater.Inflate(Resource.Layout.propinapopup, null);

            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.SetView(view);
            builder.SetTitle("¿Caunto deseas agregar de propina?");
            var propinaa = view.FindViewById <EditText>(Resource.Id.lineapropina);

            builder.SetCancelable(false)
            .SetPositiveButton("Donar", (c, ev) =>
            {
                string lo            = propinaa.Text;
                propina.Text         = "$" + lo + ".00";
                propinaagregada.Text = "$" + lo + ".00";
                float gamesa         = float.Parse(lo);
                AddData(gamesa);
            })
            .SetNegativeButton("Cancelar", (c, ev) =>
            {
                propina.Text         = "$0.00";
                propinaagregada.Text = "$0.00";
            });
            AlertDialog lala = builder.Create();

            lala.Show();
        }
Ejemplo n.º 21
0
 private void login()
 {
     if (login_admin.Checked)
     {
         cursor = myDB.SelectMyAdmindata();
         cursor.MoveToFirst();
         var un   = cursor.GetString(cursor.GetColumnIndexOrThrow("adm_name"));
         var pswd = cursor.GetString(cursor.GetColumnIndexOrThrow("adm_password"));
         if (login_username.Text == un && login_passowrd.Text == pswd)
         {
             System.Console.WriteLine("Successfully logged in!!");
             Intent newscreen = new Intent(this, typeof(Activity));
             StartActivity(newscreen);
         }
         else
         {
             alert.SetTitle("Error!");
             alert.SetMessage("Wrong Username or Password...");
             alert.SetPositiveButton("Ok", alertOKButton);
             Android.App.AlertDialog myDialog = alert.Create();
             myDialog.Show();
         }
     }
     else
     {
         cursor = myDB.SelectSalesPersonData(login_username.Text);
         cursor.MoveToFirst();
         if (cursor == null)
         {
             alert.SetTitle("Error!");
             alert.SetMessage("This email id is not registered..");
             alert.SetPositiveButton("Ok", alertOKButton);
             Android.App.AlertDialog myDialog = alert.Create();
             myDialog.Show();
         }
         else
         {
             var un    = cursor.GetString(cursor.GetColumnIndexOrThrow("sp_email"));
             var pswd  = cursor.GetString(cursor.GetColumnIndexOrThrow("sp_password"));
             var fname = cursor.GetString(cursor.GetColumnIndexOrThrow("first_name"));
             var lname = cursor.GetString(cursor.GetColumnIndexOrThrow("last_name"));
             if (login_username.Text == un && login_passowrd.Text == pswd)
             {
                 System.Console.WriteLine("Successfully logged in!!");
                 Intent newscreen = new Intent(this, typeof(sales_person_dashboard));
                 newscreen.PutExtra("email", login_username.Text);
                 newscreen.PutExtra("salesPersonName", fname + " " + lname);
                 StartActivity(newscreen);
             }
             else
             {
                 alert.SetTitle("Error!");
                 alert.SetMessage("Wrong Username or Password...");
                 alert.SetPositiveButton("Ok", alertOKButton);
                 Android.App.AlertDialog myDialog = alert.Create();
                 myDialog.Show();
             }
         }
     }
 }
Ejemplo n.º 22
0
        private void Button_Click(object sender, EventArgs e)
        {
            Android.App.AlertDialog.Builder alertDialog = new Android.App.AlertDialog.Builder(this);
            Android.App.AlertDialog         alert       = alertDialog.Create();

            if (SelectedManufacturers.Count == 0 || SelectedPriceRanges.Count == 0)
            {
                alert.SetTitle("Error");
                alert.SetMessage("Enter all data");
            }
            else
            {
                Choice.SelectedManufacturers = GetResultFromCheckBoxGroup(ref SelectedManufacturers);
                Choice.SelectedPriceRanges   = GetResultFromCheckBoxGroup(ref SelectedPriceRanges);
                bool result = database.Add(Choice);

                if (result)
                {
                    alert.SetMessage("Your choice is save.");
                }
                else
                {
                    alert.SetMessage("Your choice is not save.");
                }

                alert.SetTitle("Save");
            }
            alert.SetButton("OK", (c, ev) =>
            {
                alert.Dispose();
            });
            alert.Show();
        }
Ejemplo n.º 23
0
        void myListViewEvent(object sender, AdapterView.ItemClickEventArgs e)
        {
            var index = e.Position;

            UserObject value = myUserList[index];

            System.Console.WriteLine("Value " + value.name);

            Android.App.AlertDialog.Builder dialog = new Android.App.AlertDialog.Builder(context);
            Android.App.AlertDialog         alert  = dialog.Create();
            alert.SetTitle("Favourite!");
            alert.SetMessage("Add To Favourites?");

            alert.SetButton("Add", (c, ev) =>
            {
                dbhelper = new DBHelper(context);

                dbhelper.insertFavouritetable(value.id, value.name, value.address, value.day, value.price, value.category);
            });

            alert.SetButton2("Cancel", (c, ev) =>

            {
                var activity = new Intent(context, typeof(homeActivity));
                //activity.PutExtra("Value", value.name);
                StartActivity(activity);
            });

            alert.Show();

            /*var activity = new Intent(context, typeof(EventActivity));
             * activity.PutExtra("Value", value.name);
             * StartActivity(activity);*/
        }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            base.OnCreateView(inflater, container, savedInstanceState);

            var view = inflater.Inflate(Project.Resource.Layout.layout1, container, false);

            e1 = view.FindViewById <EditText>(Resource.Id.cname);
            e2 = view.FindViewById <EditText>(Resource.Id.number);
            e3 = view.FindViewById <EditText>(Resource.Id.expire);
            e4 = view.FindViewById <EditText>(Resource.Id.cvv);
            p  = view.FindViewById <Button>(Resource.Id.pay);

            p.Click += delegate
            {
                Android.App.AlertDialog.Builder dialog = new Android.App.AlertDialog.Builder(this.Context);
                Android.App.AlertDialog         alert  = dialog.Create();
                alert.SetTitle("Thank you");
                alert.SetMessage("Hope we see you again");
                alert.SetButton("ok", (c, ev) =>
                {
                });
                alert.Show();
            };
            return(view);
        }
Ejemplo n.º 25
0
        private async void Btn3_Click(object sender, EventArgs e)
        {
            EditText et2         = FindViewById <EditText>(Resource.Id.SMS);
            String   messageText = "Hello" + et2.Text;
            String   recipient   = "0211645518";

            try
            {
                NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID)
                                                     .SetAutoCancel(false)
                                                     .SetSmallIcon(Resource.Drawable.abc_ic_star_black_16dp)
                                                     .SetContentTitle("Notification Title")
                                                     .SetContentText("This is a sample notification");
                var notificationManager = NotificationManagerCompat.From(this);
                notificationManager.Notify(NOTIFICATION_ID, builder.Build());

                var message = new SmsMessage(messageText, new[] { recipient });
                await Sms.ComposeAsync(message);
            }
            catch (FeatureNotSupportedException)
            {
                // Sms is not supported on this device.
                Android.App.AlertDialog.Builder builder = new Android.App.AlertDialog.Builder(this);
                builder.SetMessage("SMS is not supported on this phone").
                SetTitle("Feature Not Supported");
                Android.App.AlertDialog dialog = builder.Create();
            }
            catch (Exception)
            {
                // Other error has occurred.
            }

            // Create your application here
        }
Ejemplo n.º 26
0
        void Mylist_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
        {
            Android.App.AlertDialog.Builder dialog = new Android.App.AlertDialog.Builder(this.Activity);
            Android.App.AlertDialog         alert  = dialog.Create();

            alert.SetTitle("Remove Party from Queue");
            alert.SetMessage("Are you sure you want to remove this party from the queue?");
            alert.SetButton("Yes", (c, ev) =>
            {
                var firebase = new FirebaseClient(FBURL);

                firebase
                .Child("queues")
                .Child(auth.CurrentUser.Uid)
                .Child(listQueue[e.Position].account_uid)
                .DeleteAsync();

                listQueue.Remove(listQueue[e.Position]);
                CustomQueueListAdapter adapter = new CustomQueueListAdapter(this, listQueue);

                mylist.Adapter = adapter;

                Toast.MakeText(this.Activity, "Party has been removed from the Queue", ToastLength.Short).Show();
            });
            alert.SetButton2("No", (c, ev) =>
            {
            });
            alert.Show();
        }
Ejemplo n.º 27
0
        public void ReceiveDetections(Detections detections)
        {
            SparseArray qrcodes = detections.DetectedItems;

            if (qrcodes.Size() != 0)
            {
                _txtResult.Post(() => {
                    _txtResult.Text            = ((Barcode)qrcodes.ValueAt(0)).RawValue;
                    AlertDialog.Builder dialog = new AlertDialog.Builder(this);
                    AlertDialog alert          = dialog.Create();
                    alert.SetTitle("Código de Barras");
                    alert.SetMessage(((Barcode)qrcodes.ValueAt(0)).RawValue);
                    alert.SetIcon(Resource.Drawable.logo);
                    alert.SetButton("Volver", (c, ev) =>
                    {
                        // Para actualizar una actividad desde dentro de sí mismo
                        Finish(); StartActivity(Intent);

                        GC.Collect();
                    });

                    alert.Show();
                });
            }
        }
Ejemplo n.º 28
0
 public override void OnBackPressed()
 {
     Android.App.AlertDialog.Builder builder    = new Android.App.AlertDialog.Builder(this);
     Android.App.AlertDialog         alerDialog = builder.Create();
     alerDialog.SetTitle("Gracias");
     //poner imagen de respuesta incorrecta
     //alerDialog.SetIcon(Resource.Drawable.Icon);
     alerDialog.SetMessage("Por favor danos tu opinión sobre tu experiencia con la aplicación");
     alerDialog.SetButton("Ir a feedback", (se, eve) =>
     {
         try
         {
             var uri    = Android.Net.Uri.Parse("https://docs.google.com/forms/d/e/1FAIpQLSe_BMvCLkessoOfpOSJsg1bcb49K3U_oj3OQH8r2yYMZX0tRA/viewform?usp=sf_link");
             var intent = new Intent(Intent.ActionView, uri);
             StartActivity(intent);
             Finish();
         }catch (Exception e)
         {
         }
     });
     alerDialog.SetButton2("Ahora no", (se, eve) =>
     {
         Finish();
     });
     alerDialog.CancelEvent += OnDialogCancel;
     alerDialog.Show();
     //base.OnBackPressed(); -> DO NOT CALL THIS LINE OR WILL NAVIGATE BACK
 }
Ejemplo n.º 29
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            this.SetContentView(Resource.Layout.activity_main);
            activity = this;

            BottomNavigationView navigation = (BottomNavigationView)FindViewById <BottomNavigationView>(Resource.Id.bottom_navigation);

            navigation.SetOnNavigationItemSelectedListener(this);
            Android.Support.V4.App.Fragment fragment = null;
            fragment = categoriesFragment.NewInstance();
            SupportFragmentManager.BeginTransaction()
            .Replace(Resource.Id.content_frame, fragment)
            .Commit();
            var connectivity = Connectivity.NetworkAccess;

            if (connectivity != NetworkAccess.Internet)
            {
                Android.App.AlertDialog.Builder dialog = new Android.App.AlertDialog.Builder(this);
                Android.App.AlertDialog         alert  = dialog.Create();
                alert.SetTitle("Error");
                alert.SetMessage("Device is not connected to the internet, please check network connection");
                alert.SetButton("OK", (c, ev) =>
                {
                    this.FinishAffinity();
                });
                alert.Show();
            }

            if (CheckSelfPermission(Android.Manifest.Permission.AccessCoarseLocation) != (int)Permission.Granted)
            {
                RequestPermissions(new string[] { Android.Manifest.Permission.AccessCoarseLocation, Android.Manifest.Permission.AccessFineLocation }, 0);
            }
        }
Ejemplo n.º 30
0
 private void setAlert(string message)
 {
     Android.App.AlertDialog.Builder alert       = new Android.App.AlertDialog.Builder(this);
     Android.App.AlertDialog         alertDialog = alert.Create();
     alertDialog.SetTitle(message);
     alertDialog.Show();
 }
Ejemplo n.º 31
0
        public async void Load()
        {
            LoadingDialog builder = new LoadingDialog(this).SetMessage("Загрузка...");

            Android.App.AlertDialog dialog = builder.Create();
            dialog.Show();

            string response = await Connector.GetAsync("phrase.set") ?? "{}";

            var data = JObject.Parse(response);

            if (data?["status"] == null)
            {
                Toast.MakeText(this, "Произошла ошибка :(", ToastLength.Short).Show();
                dialog.Dismiss();
                Finish();
                return;
            }

            Phrases = new List <Phrase>();
            foreach (var item in (JArray)data["result"])
            {
                Phrase ph = new Phrase {
                    Id   = Convert.ToInt32(item["id"]),
                    Text = Convert.ToString(item["text"])
                };
                Phrases.Add(ph);
            }

            BuildElements();
            dialog.Dismiss();
        }
Ejemplo n.º 32
0
        async void ExtractText()
        {
            try
            {
                //await CrossMedia.Current.Initialize();
                var xFile = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions
                {
                    SaveToAlbum = true,
                    Directory   = "Sample",
                    Name        = "test.jpg"
                });

                //svar filepath = "/storage/emulated/0/Android/data/Tesseract.Android.Tesseract.Android/files/Pictures/Sample/test_3.jpg";
                dialog = new ProgressDialog(this);
                dialog.SetMessage("Extracting Text");
                dialog.Show();
                await api.SetImage(xFile.GetStream());

                dialog.Hide();
                Android.App.AlertDialog.Builder builder1 = new Android.App.AlertDialog.Builder(this);
                builder1.SetMessage(api.Text);
                builder1.SetCancelable(true);
                Android.App.AlertDialog alert11 = builder1.Create();
                alert11.Show();
                string text = api.Text;
            }
            catch (Exception e)
            {
            }
        }
Ejemplo n.º 33
0
        void call_premium_option_menu(bool showRestricion = false)
        {
            Android.App.AlertDialog.Builder builder = new Android.App.AlertDialog.Builder(this);
            //builder.SetTitle(TranslationHelper.GetString("moreAboutPremium", ci));
            builder.SetNegativeButton(TranslationHelper.GetString("cancel", _ci), (object sender1, DialogClickEventArgs e1) => { });
            if (!_databaseMethods.UserExists())
            {
                //constraintItems = new string[] { "Подробнее о Premium", "Войти в учетную запись" };
                builder.SetPositiveButton(TranslationHelper.GetString("login", _ci), (object sender1, DialogClickEventArgs e1) =>
                {
                    StartActivity(typeof(EmailActivity));
                });
                builder.SetNeutralButton(TranslationHelper.GetString("premium", _ci), (object sender1, DialogClickEventArgs e1) =>
                {
                    StartActivity(typeof(PremiumActivity));
                });
            }

            if (showRestricion)
            {
                builder.SetMessage(TranslationHelper.GetString("workOnSeveralDevicesRestricted", _ci));
            }
            else
            {
                builder.SetMessage(TranslationHelper.GetString("cardsLimitHasBeenReached", _ci));
            }
            Android.App.AlertDialog dialog = builder.Create();
            dialog.Show();
        }
Ejemplo n.º 34
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            using (var db = new SQLiteConnection (dbPath)) {
                db.CreateTable<LogEntry> ();
            }

            // Set our view from the "main" layout resource
            SetContentView (Resource.Layout.Main);

            // Create our database if it does not already exist

            // Get our button from the layout resource,
            // and attach an event to it
            Button addFood = FindViewById<Button> (Resource.Id.AddFoodButton);

            addFood.Click += (object sender, EventArgs e) =>
            {
                AlertDialog.Builder addFoodDialogBuilder = new AlertDialog.Builder(this);
                addFoodDialogBuilder.SetTitle ("I had something to eat and it was:");
                addFoodDialogBuilder.SetSingleChoiceItems (choices, -1, clickFoodDialogList);

                addFoodDialog = addFoodDialogBuilder.Create();
                // Show the alert dialog to the user and wait for response.
                addFoodDialog.Show();
            };
        }
Ejemplo n.º 35
0
 public void OnComplete(Task task)
 {
     if (task.IsSuccessful == false)
     {
         Android.App.AlertDialog.Builder dialog = new AlertDialog.Builder(this);
         AlertDialog alert = dialog.Create();
         alert.SetTitle("Failed");
         alert.SetMessage("Request failed, something went wrong");
         alert.SetButton("OK", (c, ev) =>
         {
             // Ok button click task
         });
         alert.SetButton2("CANCEL", (c, ev) => { });
         alert.Show();
     }
     else
     {
         Android.App.AlertDialog.Builder dialog = new AlertDialog.Builder(this);
         AlertDialog alert = dialog.Create();
         alert.SetTitle("Success");
         alert.SetMessage("Request success, please check your email");
         alert.SetButton("OK", (c, ev) =>
         {
             // Ok button click task
         });
         alert.Show();
     }
 }
Ejemplo n.º 36
0
		public override ICancellableAlert Open ()
		{
			CloseDialogIfShown ();

			dialogShown = builder.Show ();

			return this;
		}
Ejemplo n.º 37
0
        public ChatFragment(string username, Socket socket, AlertDialog alert)
        {
            this.username = username;
            this.socket = socket;
            this.adapter = new ChatAdapter(chatItems);

            AttachSocketEvents(alert);
        }
Ejemplo n.º 38
0
 private void ShowDialogInUiThread(AlertDialog.Builder builder)
 {
     CloseDialog();
     Mvx.Resolve<IMvxMainThreadDispatcher>().RequestMainThreadAction(() =>
     {
         _currentDialog = builder.Create();
         _currentDialog.Show();
     });
 }
 private void ShowAlertDialog(string title, string message)
 {
     if (_alertDialog != null && _alertDialog.IsShowing) return;
     _alertDialog = new AlertDialog.Builder(Context).Create();
     _alertDialog.SetTitle(title);
     _alertDialog.SetMessage(message);
     _alertDialog.SetButton("OK", (alertsender, args) => { });
     _alertDialog.Show();
 }
Ejemplo n.º 40
0
		public MyListDialog(Context context, AlertDialog.Builder builder,
			EventHandler<DialogClickEventArgs> listener) {

			mItemMap = new Dictionary<string, string>();
			mAdapter = new ArrayAdapter<string>(context, Android.Resource.Layout.SelectDialogSingleChoice);

			// Create dialog from builder
			builder.SetAdapter(mAdapter, listener);
			mDialog = builder.Create();
		}
Ejemplo n.º 41
0
        private void AttachSocketEvents(AlertDialog alert)
        {
            // Whenever the server emits "login", log the login message
            socket.On("login", data =>
            {
                if (alert != null)
                {
                    alert.Dismiss();
                    alert.Dispose();
                    alert = null;
                }

                var d = Data.FromData(data);
                connected = true;
                // Display the welcome message
                AddMessage("Welcome to Socket.IO Chat – ", true);
                AddParticipantsMessage(d.numUsers);
            });
            // Whenever the server emits "new message", update the chat body
            socket.On("new message", data =>
            {
                var d = Data.FromData(data);
                AddMessage(d.message, username: d.username);
            });
            // Whenever the server emits "user joined", log it in the chat body
            socket.On("user joined", data =>
            {
                var d = Data.FromData(data);
                AddMessage(d.username + " joined");
                AddParticipantsMessage(d.numUsers);
            });
            // Whenever the server emits "user left", log it in the chat body
            socket.On("user left", data =>
            {
                var d = Data.FromData(data);
                AddMessage(d.username + " left");
                AddParticipantsMessage(d.numUsers);
                UpdateChatTyping(d.username, true);
            });
            // Whenever the server emits "typing", show the typing message
            socket.On("typing", data =>
            {
                var d = Data.FromData(data);
                UpdateChatTyping(d.username, false);
            });
            // Whenever the server emits "stop typing", kill the typing message
            socket.On("stop typing", data =>
            {
                var d = Data.FromData(data);
                UpdateChatTyping(d.username, true);
            });
        }
Ejemplo n.º 42
0
 protected override void OnPrepareDialogBuilder(AlertDialog.Builder builder)
 {
     EventHandler<DialogClickEventArgs> onClick = (o, e) =>
                       {
                           var dialog = (AlertDialog) o;
                           SetValueIndex((int) e.Which);
                           OnClick((AlertDialog) o, DialogInterfaceButton.Positive);
                           dialog.Dismiss();
                       };
     var adapter = CreateAdapter();
     builder.SetSingleChoiceItems(adapter, FindIndexOfValue(Value), onClick);
     
     HideOkButton(builder);
 }
Ejemplo n.º 43
0
		public static void MakeErrorPopUp(Activity activity, ErrorType error)
		{
			if (activity == null) throw new ArgumentNullException("activity");

			activity.RunOnUiThread(() =>
			{
				_errorDialog = new AlertDialog.Builder(activity)
					.SetPositiveButton(Resource.String.TryAgainButtonText, OnTryAgainButtonClicked)
					.SetTitle(ResolveErrorTitle(error))
					.SetMessage(ResolveErrorMessage(error))
					.Create();
				_errorDialog.Show();
			});
		}
        protected override void OnElementChanged(ElementChangedEventArgs<Page> e)
        {
            base.OnElementChanged(e);

            var page = e.NewElement as MainPage;

            if (page != null) {

                MessagingCenter.Subscribe(page, "KillActionSheet", (MainPage sender) => {

                    if (actionSheet != null) actionSheet.Dismiss();

                });

                MessagingCenter.Subscribe(page, "DisplayCustomAndroidActionSheet", (MainPage sender, CustomAndroidActionSheetArguments args) => {

                    var builder = new AlertDialog.Builder (Forms.Context);

                    builder.SetTitle(args.Title);

                    var items = args.Buttons.ToArray();

                    builder.SetItems(items, (sender2, args2) => args.Result.TrySetResult(items[args2.Which]));

                    if (args.Cancel != null)
                        builder.SetPositiveButton(args.Cancel, delegate {
                            args.Result.TrySetResult(args.Cancel);
                        });

                    if (args.Destruction != null)
                        builder.SetNegativeButton(args.Destruction, delegate {
                            args.Result.TrySetResult(args.Destruction);
                        });

                    actionSheet = builder.Create();

                    builder.Dispose();

                    actionSheet.SetCanceledOnTouchOutside(true);

                    actionSheet.CancelEvent += (sender3, ee) => args.SetResult(null);

                    actionSheet.Show();
                });
            }
        }
Ejemplo n.º 45
0
        private static Task<int?> PlatformShow(string title, string description, List<string> buttons)
        {
            tcs = new TaskCompletionSource<int?>();
            Game.Activity.RunOnUiThread(() =>
            {
                alert = new AlertDialog.Builder(Game.Activity).Create();

                alert.SetTitle(title);
                alert.SetMessage(description);

                alert.SetButton((int)DialogButtonType.Positive, buttons[0], (sender, args) =>
                {
                    if (!tcs.Task.IsCompleted)
                        tcs.SetResult(0);
                });

                if (buttons.Count > 1)
                {
                    alert.SetButton((int)DialogButtonType.Negative, buttons[1], (sender, args) =>
                    {
                        if (!tcs.Task.IsCompleted)
                            tcs.SetResult(1);
                    });
                }

                if (buttons.Count > 2)
                {
                    alert.SetButton((int)DialogButtonType.Neutral, buttons[2], (sender, args) =>
                    {
                        if (!tcs.Task.IsCompleted)
                            tcs.SetResult(2);
                    });
                }

                alert.CancelEvent += (sender, args) =>
                {
                    if (!tcs.Task.IsCompleted)
                        tcs.SetResult(null);
                };

                alert.Show();
            });

            return tcs.Task;
        }
Ejemplo n.º 46
0
        private static Task<string> PlatformShow(string title, string description, string defaultText, bool usePasswordMode)
        {
            tcs = new TaskCompletionSource<string>();

            Game.Activity.RunOnUiThread(() =>
            {
                alert = new AlertDialog.Builder(Game.Activity).Create();

                alert.SetTitle(title);
                alert.SetMessage(description);

                var input = new EditText(Game.Activity) { Text = defaultText };

                if (defaultText != null)
                    input.SetSelection(defaultText.Length);

                if (usePasswordMode)
                    input.InputType = Android.Text.InputTypes.ClassText | Android.Text.InputTypes.TextVariationPassword;

                alert.SetView(input);

                alert.SetButton((int)DialogButtonType.Positive, "Ok", (sender, args) =>
                {
                    if (!tcs.Task.IsCompleted)
                        tcs.SetResult(input.Text);
                });

                alert.SetButton((int)DialogButtonType.Negative, "Cancel", (sender, args) =>
                {
                    if (!tcs.Task.IsCompleted)
                        tcs.SetResult(null);
                });

                alert.CancelEvent += (sender, args) =>
                {
                    if (!tcs.Task.IsCompleted)
                        tcs.SetResult(null);
                };

                alert.Show();
            });

            return tcs.Task;
        }
Ejemplo n.º 47
0
 void DelegatDlaItemClick(AdapterView.ItemClickEventArgs e)
 {
     Tuple<string, string> item = lv.GetItemAtPosition(e.Position).Cast<Tuple<string, string>>();
     if (item.Item1 == nickname)
         return;
     ad = new AlertDialog.Builder(this).Create();
     ad.SetCancelable(false); // This blocks the 'BACK' button
     ad.SetMessage(string.Format("Czy chcesz zaprosiæ u¿ytkownika {0} do gry?", item.Item1));
     ad.SetButton("Nie", delegate
     {
     });
     ad.SetButton2("Tak", delegate
     {
         byte[] buff = new byte[MainActivity.MAX_LENGTH];
         buff = System.Text.Encoding.ASCII.GetBytes(string.Format("{0};{1}", Convert.ToInt32(MessageTypes.Invite), item.Item1));
         Sockets.client.GetStream().Write(buff, 0, buff.Length);
     });
     ad.Show();
 }
		public static void BrandAlertDialog(AlertDialog dialog)
		{
	//		try
//			{
//				Resources resources = dialog.Context.Resources;
//				var color = dialog.Context.Resources.GetColor(Resource.Color.accent);
//
//				var alertTitleId = resources.GetIdentifier("alertTitle", "id", "android");
//				var alertTitle = (TextView)dialog.Window.DecorView.FindViewById(alertTitleId);
//				alertTitle.SetTextColor(color); // change title text color
//
//				var titleDividerId = resources.GetIdentifier("titleDivider", "id", "android");
//				var titleDivider = dialog.Window.DecorView.FindViewById(titleDividerId);
//				titleDivider.SetBackgroundColor(color); // change divider color
//			}
//			catch
//			{
//				//Can't change dialog brand color
//			}
		}
Ejemplo n.º 49
0
		public void DatePickDialogShow(EditText edit_birth)
		{
			var datepickerlayout = (LinearLayout) activity.LayoutInflater.Inflate (Resource.Layout.commondatepickerlayout, null);
			datePicker = datepickerlayout.FindViewById<DatePicker> (Resource.Id.datepicker);
			InitDatePicker (datePicker);
		
			var builder = new AlertDialog.Builder (activity).SetView(datepickerlayout);
			builder.SetPositiveButton ("设置", (sender, e) => {
				dialog.Dismiss();	
				edit_birth.Text = dateTime;

			});
			builder.SetNegativeButton ("取消", (sender, e) => {
				dialog.Dismiss();	

			});
			dialog= builder.Create ();

			dialog.Show();
			OnDateChanged (null, 0, 0, 0);
		}
Ejemplo n.º 50
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Create your application here
            SetTheme(Android.Resource.Style.ThemeLight);
            SetContentView(Resource.Layout.CrearDenuncia);
			//Alert message
			AlertDialog.Builder builder = new AlertDialog.Builder(this);
			alert = builder.Create();
            if (Shared.address != null)
            {
                spnTipoNombre = FindViewById<Spinner>(Resource.Id.spnTipoNombre);
                spnTipoNombre.RequestFocus();
                tipos = new string[]{
                    "Corte de servicio",
                    "Fuga de Agua",
                    "Daño a Infraestructura",
                    "Otros"
                };
                ids = new int[] { 1, 2, 3, 4 };
                ArrayAdapter<string> spinnerArrayAdapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleSpinnerItem, tipos);
                spinnerArrayAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
                spnTipoNombre.Adapter = spinnerArrayAdapter;
                spnTipoNombre.ItemSelected += spnTipoNombre_ItemSelected;
                txtDescripcion = FindViewById<EditText>(Resource.Id.txtInsertDescripcion);
                txtvInsertPais = FindViewById<TextView>(Resource.Id.txtvInsertPais);
                txtvInsertAutor = FindViewById<TextView>(Resource.Id.txtvInsertAutor);
                txtvinsertCiudad = FindViewById<TextView>(Resource.Id.txtvInsertCiudad);
                txtvInsertCalle = FindViewById<TextView>(Resource.Id.txtvInsertCalle);
                btnInsertDenuncia = FindViewById<Button>(Resource.Id.btnInsertDenuncia);
                imgFoto = FindViewById<ImageView>(Resource.Id.imgInsertFoto);
                txtvInsertPais.Text = Shared.address.CountryName;
                txtvinsertCiudad.Text = Shared.address.Locality;
                txtvInsertCalle.Text = Shared.address.FeatureName;
                txtvInsertAutor.Text = "Luis Jovel";
                btnInsertDenuncia.Click += btnInsertDenuncia_Click;
                imgFoto.Click += imgFoto_Click;
            }
        }
Ejemplo n.º 51
0
		public void TimePickDialogShow(EditText edit_inputTime)
		{
			var timepickerlayout = (LinearLayout) activity.LayoutInflater.Inflate (Resource.Layout.commontimepickerlayout, null);
			timePicker = (TimePicker) timepickerlayout.FindViewById<TimePicker>(Resource.Id.timepicker); 
			InitTimePicker (timePicker);
			timePicker.SetIs24HourView(Java.Lang.Boolean.ValueOf(true)); 
			timePicker.SetOnTimeChangedListener(this);  
			var builder = new AlertDialog.Builder (activity).SetView(timepickerlayout);
			builder.SetPositiveButton ("设置", (sender, e) => {
				dialog.Dismiss();	
				edit_inputTime.Text = dateTime;

			});
			builder.SetNegativeButton ("取消", (sender, e) => {
				dialog.Dismiss();	

			});
			dialog= builder.Create ();

			dialog.Show();
			OnTimeChanged (null,0,0);
		}
Ejemplo n.º 52
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            #region Step 1. Load your main layout

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.main);

            #endregion

            #region Step 2. Get the button that was declared in xml

            var b = FindViewById<Button>(Resource.Id.flag_button);
            b.SetBackgroundDrawable(Resources.GetDrawable(Resource.Drawable.flag));

            #endregion

            #region Step 3. Build Alert Dialog

            var builder = new AlertDialog.Builder(this);
            builder.SetMessage(Resource.String.dialog_text)
                .SetCancelable(false)
                .SetTitle(GetString(Resource.String.dialog_title))
                .SetPositiveButton("Done", (o, args) => ((Dialog) o).Dismiss());

            _alert = builder.Create();

            #endregion

            #region Step 4. Wire up button click event to show alert.

            b.Click += (o, args) => _alert.Show();

            #endregion
        }
 protected override void InitializePositiveAndNegativeButtons(AlertDialog.Builder builder)
 {
     builder.SetPositiveButton(DoneText, delegate { Done(); });
     builder.SetNegativeButton(CancelText, delegate { });
 }
Ejemplo n.º 54
0
 private static void HideOkButton(AlertDialog.Builder builder)
 {
     builder.SetPositiveButton("", (o, e) => { });
 }
Ejemplo n.º 55
0
		public void OnConnectionRequest (string remoteEndpointId, string remoteDeviceId, string remoteEndpointName, byte[] payload)
		{
			DebugLog ("onConnectionRequest:" + remoteEndpointId + ":" + remoteEndpointName);

			// This device is advertising and has received a connection request. Show a dialog asking
			// the user if they would like to connect and accept or reject the request accordingly.
			mConnectionRequestDialog = new AlertDialog.Builder (this)
				.SetTitle ("Connection Request")
				.SetMessage ("Do you want to connect to " + remoteEndpointName + "?")
				.SetCancelable (false)
				.SetPositiveButton ("Connect", (sender, e) => {
					byte[] pLoad = null;
					NearbyClass.Connections.AcceptConnectionRequest (mGoogleApiClient, 
						remoteEndpointId, pLoad, this).SetResultCallback ((Statuses status) => {
							if (status.IsSuccess) {
								DebugLog ("acceptConnectionRequest: SUCCESS");
								mOtherEndpointId = remoteEndpointId;
								UpdateViewVisibility (NearbyConnectionState.Connected);
							} else {
								DebugLog ("acceptConnectionRequest: FAILURE");
							}
						});
				})
				.SetNegativeButton ("No", (sender, e) => NearbyClass.Connections.RejectConnectionRequest (mGoogleApiClient, remoteEndpointId))
				.Create ();

			mConnectionRequestDialog.Show ();
		}
 public bool DetachWithIME()
 {
     if (CanDetachWithIME())
     {
         if (alertDialog != null && alertDialog.IsShowing)
         {
             alertDialog.Dismiss();
             alertDialog.Dispose();
             alertDialog = null;
         }
     }
     return true;
 }
Ejemplo n.º 57
0
        private void FindServers()
        {
            RemoveDiscoveryListener ();
            _serverIps = new List<string> ();
            var builder = new AlertDialog.Builder (this);
            builder.SetTitle ("Pick a server to pair with:");
            _alertDialog = builder.Create ();
            _listServers = new ListView (this);
            _listServers.Adapter = new ArrayAdapter<string> (this, Android.Resource.Layout.SimpleSpinnerItem, _serverIps);
            _listServers.ItemClick += _listServersItemClick;
            _alertDialog.SetView (_listServers);
            _alertDialog.Show ();

            _autoDiscovery = new AutoDiscoveryClient ();
            _autoDiscovery.NewServerFound += _newServerFound;
            _autoDiscovery.Start ();
        }
Ejemplo n.º 58
0
 protected override void OnStop()
 {
     if (_listServers != null) {
         _listServers.ItemClick -= _listServersItemClick;
     }
     if (_alertDialog != null) {
         _alertDialog.Dismiss ();
         _alertDialog = null;
     }
     RemoveDiscoveryListener ();
     base.OnStop ();
 }
Ejemplo n.º 59
0
 private void _listServersItemClick(object sender, AdapterView.ItemClickEventArgs e)
 {
     _listServers.ItemClick -= _listServersItemClick;
     RemoveDiscoveryListener ();
     _txtIp.Text = _serverIps [e.Position];
     _btnSendMessage.Enabled = true;
     _txtMessage.Enabled = true;
     _alertDialog.Dismiss ();
     _alertDialog = null;
 }
        public string ShowKeyboardInput(
            string defaultText)
        {

            var waitHandle = new EventWaitHandle(false, EventResetMode.AutoReset);

            OnKeyboardWillShow();

            IsVisible = true;



            CCGame.Activity.RunOnUiThread(() =>
                {
                    var alert = new AlertDialog.Builder(Game.Activity);

                    var input = new EditText(Game.Activity) { Text = defaultText };

                    // Set the input fields input filter to accept only uppercase
                    input.SetFilters ( new Android.Text.IInputFilter[] { new Android.Text.InputFilterAllCaps() });

                    if (defaultText != null)
                    {
                        input.SetSelection(defaultText.Length);
                    }
                    alert.SetView(input);

                    alert.SetPositiveButton("Ok", (dialog, whichButton) =>
                        {
                            ContentText = input.Text;
                            waitHandle.Set();
                            IsVisible = false;
                            OnKeyboardWillHide();
                        });

                    alert.SetNegativeButton("Cancel", (dialog, whichButton) =>
                        {
                            ContentText = null;
                            waitHandle.Set();
                            IsVisible = false;
                            OnKeyboardWillHide();
                        });
                    alert.SetCancelable(false);

                    alertDialog = alert.Create();
                    alertDialog.Show();
                    OnKeyboardDidShow();

                });
            waitHandle.WaitOne();

            if (alertDialog != null)
            {
                alertDialog.Dismiss();
                alertDialog.Dispose();
                alertDialog = null;
            }

            OnReplaceText(new CCIMEKeybardEventArgs(contentText, contentText.Length));
            IsVisible = false;

            return contentText;
        }