示例#1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);
            FindViewById<EditText>(Resource.Id.modemPassword).RequestFocus();

            FindViewById<Button>(Resource.Id.next).Click += (s,e) => {
                if(ModemPassword=="")
                {
                    var diag=new AlertDialog.Builder(this);
                    diag.SetTitle("Device Access Code Required!");
                    diag.SetMessage("A password or Device Access Code is required! It is usually a 10-digit number printed on your modem");
                    diag.SetIcon(Android.Resource.Drawable.IcDialogAlert);
                    diag.SetNeutralButton("Ok", new EventHandler<DialogClickEventArgs>((s2, e2) => {} ));
                    diag.Show();
                    return;
                }
                var controller = new Intent(this, typeof(ControllerActivity));
                controller.PutExtra("address", ModemAddress);
                controller.PutExtra("password", ModemPassword);
                StartActivity(controller);
            };
            // Get our button from the layout resource,
            // and attach an event to it
            //must get address and password in this context because it can change later, but other threads can't access it
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

#if __ANDROID_14__
            Window.RequestFeature(WindowFeatures.ActionBar);
            ActionBar.SetDisplayHomeAsUpEnabled(ViewModel.CanGoBack);
#endif

            SetContentView(Resource.Layout.identityproviderlistview);

            _loadingToken = ViewModel.WeakSubscribe(() => ViewModel.LoadingIdentityProviders, (sender, args) =>
            {
                if (ViewModel.LoadingIdentityProviders)
                    LoadingDialog.Show();
                else
                    LoadingDialog.Dismiss();

                InvalidateOptionsMenu();
            });

            ViewModel.LoginError += (sender, args) =>
            {
                var builder = new AlertDialog.Builder(this);
                builder.SetTitle("Error");
                builder.SetIcon(Android.Resource.Drawable.IcDialogAlert);
                builder.SetMessage(args.Message);
                builder.SetPositiveButton("Dismiss", (s, e) => { });
                builder.Create().Show();
            };
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.identityproviderlistview);

            _loadingToken = ViewModel.WeakSubscribe(() => ViewModel.LoadingIdentityProviders, (sender, args) =>
            {
                if (ViewModel.LoadingIdentityProviders)
                    LoadingDialog.Show();
                else
                    LoadingDialog.Dismiss();

                InvalidateOptionsMenu();
            });

            ViewModel.LoginError += (sender, args) =>
            {
                var builder = new AlertDialog.Builder(this);
                builder.SetTitle("Error");
                builder.SetIcon(Android.Resource.Drawable.IcDialogAlert);
                builder.SetMessage(args.Message);
                builder.SetPositiveButton("Dismiss", (s, e) => { });
                builder.Create().Show();
            };
        }
示例#4
0
        public void AskForString(string message, string title, System.Action<string> returnString)
        {
            var activity = Mvx.Resolve<IMvxAndroidCurrentTopActivity> ().Activity;
            var builder = new AlertDialog.Builder(activity);
            builder.SetIcon(Resource.Drawable.ic_launcher);
            builder.SetTitle(title ?? string.Empty);
            builder.SetMessage(message);
            var view = View.Inflate(activity, Resource.Layout.dialog_add_member, null);
            builder.SetView(view);

            var textBoxName = view.FindViewById<EditText>(Resource.Id.name);

            builder.SetCancelable(true);
            builder.SetNegativeButton(Resource.String.cancel, delegate { });//do nothign on cancel

            builder.SetPositiveButton(Resource.String.ok, delegate
                {

                    if (string.IsNullOrWhiteSpace(textBoxName.Text))
                        return;

                returnString(textBoxName.Text.Trim());
                });

            var alertDialog = builder.Create();
            alertDialog.Show();
        }
 public MessageForm(object _base, string title, string[] body)
 {
     ad = new AlertDialog.Builder(AndroidFormsAdapter.CurrentView.Context);
     ad.SetMessage(body[0]); //TODO
     ad.SetIcon(Resource.Drawable.IcMenuHelp);
     ad.SetTitle(title);
     ad.SetPositiveButton(Resource.String.Ok, (ob, args) => { });
 }
 public static int Show(string text, string title)
 {
     var ad = new AlertDialog.Builder(AndroidFormsAdapter.CurrentView.Context);
     ad.SetMessage(text);
     ad.SetIcon(Resource.Drawable.IcMenuHelp);
     ad.SetTitle(title);
     ad.SetPositiveButton(Resource.String.Ok, (ob, args) => { });
     ad.Create().Show();
     return 0;
 }
示例#7
0
文件: second.cs 项目: hatimr/Mileage
        public void test(Action<bool> callback,string message)
        {
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.SetTitle(Android.Resource.String.DialogAlertTitle);
            builder.SetIcon(Android.Resource.Drawable.IcDialogAlert);
            builder.SetMessage(message);
            builder.SetPositiveButton("OK", (sender, e) => {callback(true);});

            builder.Show();
        }
示例#8
0
        private void NativeShowAsync()
        {
            AlertDialog.Builder dialog = new AlertDialog.Builder(UIElement.StaticContext);

            if (this.Content != null)
            {
                dialog.SetMessage(this.Content);
            }

            if (this.Title != null)
            {
                dialog.SetTitle(this.Title);
            }

            dialog.SetIcon(Android.Resource.Drawable.IcDialogAlert);

            if(this.Commands == null || this.Commands.Count() < 1)
            {
                return;
            }

            if (this.Commands.Count() > 0)
            {
                dialog.SetNeutralButton(this.Commands[0].Label, (sender, e) =>
                {
                    if (this.Commands[0].Action != null)
                    {
                        this.Commands[0].Action(this.Commands[0]);
                    }
                });
            }

            if (this.Commands.Count() > 1)
            {
                dialog.SetPositiveButton(this.Commands[1].Label, (sender, e) =>
                {
                    if (this.Commands[1].Action != null)
                    {
                        this.Commands[1].Action(this.Commands[1]);
                    }
                });
            }

            if (this.Commands.Count() > 2)
            {
                dialog.SetNegativeButton(this.Commands[2].Label, (sender, e) =>
                {
                    if (this.Commands[2].Action != null)
                    {
                        this.Commands[2].Action(this.Commands[2]);
                    }
                });
            }
            UIElement.StaticContext.RunOnUiThread( () => dialog.Show());
        }
		protected override void OnResume(){
			base.OnResume();
			FillListPreference ();
			LoadSettings();
			if (!CreateDeviceList ()) {
				AlertDialog.Builder dialog = new AlertDialog.Builder(new ContextThemeWrapper(this, Android.Resource.Style.ThemeTranslucentNoTitleBar));
				//AlertDialog	dialog = new  AlertDialog.Builder(this).Create();
				dialog.SetIcon(Android.Resource.Drawable.IcDialogInfo);
				dialog.SetTitle("Select Bluetooth Device");
				dialog.SetMessage("No Bluetooth Device has been paired with Phone. Press Ok to pair a device");
				dialog. SetPositiveButton("OK", delegate(object sen, DialogClickEventArgs eventArgs) {
					Intent intentBluetooth = new Intent();
					intentBluetooth.SetAction(Android.Provider.Settings.ActionBluetoothSettings);
					StartActivity(intentBluetooth);
				});
				dialog.SetNegativeButton("Cancel",delegate {});
				dialog.SetIcon(Android.Resource.Drawable.IcDialogInfo);
				dialog.Show();
			}
		}
示例#10
0
        public override Dialog OnCreateDialog(Bundle savedInstanceState)
        {
            var builder = new AlertDialog.Builder(this.GetActivity());
            builder.SetTitle("Automatic Update");
            builder.SetIcon(Android.R.Drawable.Ic_dialog_alert);
            builder.SetPositiveButton("Update Now", this);
            builder.SetNegativeButton("Cancel", this);
            builder.SetMessage("A newer version is available... Update now?");

            return builder.Create();
        }
示例#11
0
        void ShowAlert (string message)
        {
            AlertDialog.Builder builder = new AlertDialog.Builder (this.ctx);
            builder.SetTitle (Android.Resource.String.DialogAlertTitle);
            builder.SetIcon (Android.Resource.Drawable.IcDialogAlert);
            builder.SetMessage (message);
            builder.SetPositiveButton ("OK", (sender, e) => {
            });

            builder.Show ();
        }
示例#12
0
		void ShowEmptyChannelAlert ()
		{
			AlertDialog.Builder builder = new AlertDialog.Builder(this);
			builder.SetTitle(Android.Resource.String.DialogAlertTitle);
			builder.SetIcon(Android.Resource.Drawable.IcDialogAlert);
			builder.SetMessage("Please enter a channel name");
			builder.SetPositiveButton("OK", (sender, e) =>
			    {
				});
			
			builder.Show();
		}
示例#13
0
        /// <summary>Alerts the user with a simple OK dialog and provides a <paramref name="message"/>.</summary>
        /// <param name="message">The message.</param>
        /// <param name="title">The title.</param>
        /// <param name="okbtnText">The okbtn text.</param>
        public void Alert(string message, string title, string okbtnText)
        {
            var top = Mvx.Resolve<IMvxAndroidCurrentTopActivity>();
            var act = top.Activity;

            var adb = new AlertDialog.Builder(act);
            adb.SetTitle(title);
            adb.SetMessage(message);
            adb.SetIcon(Resource.Drawable.Icon);
            adb.SetPositiveButton(okbtnText, (sender, args) => { /* some logic */ });
            adb.Create().Show();
        }
示例#14
0
        public static void ShowOKPopup(Context context, int titleId, int messageId, Action<bool> callback)
        {
            var themeId = Settings.DarkTheme? Resource.Style.AlertThemeDark : Resource.Style.AlertThemeLight;
            var builder = new AlertDialog.Builder(new ContextThemeWrapper(context, themeId));
            builder.SetIcon(Resource.Drawable.ic_launcher);
            builder.SetTitle(titleId);
            builder.SetMessage(messageId);
            builder.SetPositiveButton(Resource.String.ok, delegate
            {
                callback(true);
            });

            var alertDialog = builder.Create();
            alertDialog.Show();
        }
示例#15
0
        public static void ShowListPopup(Context context, int titleId, int itemArray, Action<int> callback)
        {
            var themeId = Settings.DarkTheme ? Resource.Style.AlertThemeDark : Resource.Style.AlertThemeLight;
            var builder = new AlertDialog.Builder(new ContextThemeWrapper(context, themeId));
            builder.SetTitle(titleId);
            builder.SetIcon(Resource.Drawable.ic_launcher);

            builder.SetItems(itemArray, (sender, args) => callback(args.Which));
            builder.SetCancelable(true);
            builder.SetNegativeButton(Resource.String.cancel, delegate { });

            var alertDialog = builder.Create();

            alertDialog.Show();
        }
示例#16
0
        void ShowAlert(object sender, EventArgs e)
        {
            // make a new alert dialog builder, passing in the current Context
            AlertDialog.Builder dialog = new AlertDialog.Builder (this);

            dialog.SetTitle ("My Alert Dialog");
            dialog.SetIcon (Resource.Drawable.Icon);
            dialog.SetMessage ("Add to click count?");
            dialog.SetNeutralButton ("OK", delegate {
                count++;
                button.Text = count + " clicks!";
            });
            dialog.SetNegativeButton ("Cancel", delegate {
                // add code to handle cancel button click, if necessary
            });

            dialog.Show ();
        }
示例#17
0
		static public void Alert (Context ctx, string title, string message, bool CancelButton, Action<Result> callback = null)
		{
			AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
			builder.SetTitle(title);
			builder.SetIcon(Resource.Drawable.Icon);
			builder.SetMessage(message);

			builder.SetPositiveButton("Ok", (sender, e) => {
				if(callback != null) callback(Result.Ok);
			});

			if (CancelButton) {
				builder.SetNegativeButton("Cancel", (sender, e) => {
					if(callback != null) callback(Result.Canceled);
				});
			}

			builder.Show();
		}
示例#18
0
        public void Alert(string title, string message, bool CancelButton, Action<Result> callback)
        {
            AlertDialog.Builder builder = new AlertDialog.Builder (this);
            builder.SetTitle (title);
            builder.SetIcon (Resource.Drawable.ic_launcher);
            builder.SetMessage (message);

            builder.SetPositiveButton ("Ok", (sender, e) => {
                callback (Result.Ok);
            });

            if (CancelButton) {
                builder.SetNegativeButton ("Cancel", (sender, e) => {
                    callback (Result.Canceled);
                });
            }

            builder.Show ();
        }
示例#19
0
        public static void ShowAlertDialog(Context context, string title, string message,
                                    bool isSuccessStatus)
        {
            var alertDialog = new AlertDialog.Builder(context).Create();

            // Setting Dialog Title
            alertDialog.SetTitle(title);

            // Setting Dialog Message
            alertDialog.SetMessage(message);

            // Setting alert dialog icon
            alertDialog.SetIcon(isSuccessStatus ? Resource.Drawable.success : Resource.Drawable.fail);

            // Setting OK Button
            alertDialog.SetButton("OK", (sender, args) => { });

            // Showing Alert Message
            alertDialog.Show();
        }
示例#20
0
 void ButAbt_Click(object sender, EventArgs e)
 {
     CompanyInfo comp= DataHelper.GetCompany (pathToDatabase);
     View messageView = LayoutInflater.Inflate(Resource.Layout.About, null, false);
     PackageInfo pInfo = PackageManager.GetPackageInfo (PackageName, 0);
     // When linking text, force to always use default color. This works
     // around a pressed color state bug.
     TextView textView = (TextView) messageView.FindViewById(Resource.Id.about_credits);
     TextView textDesc = (TextView) messageView.FindViewById(Resource.Id.about_descrip);
     TextView textVer = (TextView) messageView.FindViewById(Resource.Id.about_ver);
     //textDesc.Text = Html.FromHtml (Resources.GetString(Resource.String.app_descrip))..ToString();
     textView.Text = "For inquiry, please contact " + comp.SupportContat;
     textVer .Text = "Build Version : "+pInfo.VersionName;
     AlertDialog.Builder builder = new AlertDialog.Builder(this);
     builder.SetIcon(Resource.Drawable.Icon);
     builder.SetTitle(Resource.String.app_name);
     builder.SetView(messageView);
     builder.Create();
     builder.Show();
 }
示例#21
0
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);

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

			var btnLogin = FindViewById<Button> (Resource.Id.btnLogin);
			var btnPostWall = FindViewById<Button> (Resource.Id.btnPostWall);
			var btnRemovePost = FindViewById<Button> (Resource.Id.btnRemovePost);
			var btnGraphSample = FindViewById<Button> (Resource.Id.btnGraphSample);
			var btnFQLSample = FindViewById<Button> (Resource.Id.btnFQLSample);
			
			
			btnLogin.Click += (sender, e) => {
				var webAuth = new Intent (this, typeof (FBWebViewAuthActivity));
				webAuth.PutExtra ("AppId", AppId);
				webAuth.PutExtra ("ExtendedPermissions", ExtendedPermissions);
				StartActivityForResult (webAuth, 0);
			};

			btnPostWall.Click += HandlePostHiToWall;
			btnRemovePost.Click += HandleRemoveHiFromWall;
			btnGraphSample.Click += HandleGraphApiSample;
			btnFQLSample.Click += HandleFqlSample;

			if (AppId == "YOUR_FACEBOOK_APP_ID_HERE") {
				
				string msg ="Please visit \n https://developers.facebook.com/ \n " +
					"to get one or replace \"AppId\" Constant inside \"Activity1\" " +
						"class if you already have it \n =D ";

				AlertDialog.Builder builder = new AlertDialog.Builder(this);
				builder.SetTitle("Get/Replace Facebook App ID");
				builder.SetIcon(Android.Resource.Drawable.Icon);
				builder.SetMessage(msg);	
				builder.Show();
			}
		}
示例#22
0
        public static Random _random = new Random(); // Randomizer function

        #endregion Fields

        #region Methods

        // Result popup message method
        public bool resultMessage(string message)
        {
            string usersNameData = Intent.GetStringExtra ("UsernameData" ?? "Data not available"); // Retrieving data using the Intent's data name "UsernameData"

            bool popupResult = false;

            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.SetTitle("Resultaat!");
            builder.SetIcon(Resource.Drawable.game_icon_small);
            builder.SetMessage(message);
            builder.SetPositiveButton("Afsluiten", delegate {
                // Open the popup window
                popupResult = true;

                // Pass user data onto MenuActivity
                var intentBackup = new Intent (this, typeof(MenuActivity)); // Create an intent for MenuActivity, giving it the name usersNameData
                intentBackup.PutExtra ("UsernameData", usersNameData); // Adding a name and a value to the Intent

                // Start the MenuActivity based on the "Intent"
                StartActivity(intentBackup);
            });

            builder.SetNegativeButton("Opnieuw", (sender, e) =>
            {
                // Pass user data onto SettingsActivity
                var intentBackup = new Intent (this, typeof(MultiplayerActivity)); // Create an intent for SettingActivity, giving it the name usersNameData
                intentBackup.PutExtra ("UsernameData", usersNameData); // Adding a name and a value to the Intent

                // Start the MenuActivity based on the "Intent"
                StartActivity(intentBackup);

                // Close the popup window
                popupResult = false;
            });

            builder.Show();
            return popupResult;
        }
示例#23
0
 private void RenderResults(List<Product> products)
 {
     if (products == null || products.Count == 0)
     {
         _progressDialog.Dismiss ();
         var alertDialog = new AlertDialog.Builder(this).Create();
         alertDialog.SetTitle("Search Results");
         alertDialog.SetMessage("We were unable to find any matches in the catalog.");
         alertDialog.SetIcon(Resource.Drawable.icon);
         alertDialog.SetButton("OK", (o, e) =>
         {
             alertDialog.Dismiss();
             Finish();
         });
         alertDialog.Show();
     }
     else
     {
         SetContentView (Resource.Layout.SearchResults);
         ListView.SetBackgroundColor (G.Color.Transparent);
         ListAdapter = new ProductListAdapter(this, products);
         _progressDialog.Dismiss ();
     }
 }
        protected override Dialog OnCreateDialog(int id)
        {
            switch (id)
            {
                case DIALOG_PROGRESS:
                    return ProgressDialog.Show(this, "", GetString(Resource.String.loading));
                case DIALOG_ERROR:
                    var e = new AlertDialog.Builder(this);
                    e.SetPositiveButton(Resource.String.too_bad, delegate { });
                    e.SetMessage("");
                    return e.Create();
                case DIALOG_SUCCESS:
                    var s = new AlertDialog.Builder(this);
                        s.SetTitle(Resource.String.scoreloop);
                        s.SetIcon(Resources.GetDrawable(Resource.Drawable.Icon));
                        s.SetPositiveButton(Resource.String.awesome, delegate { });
                        s.SetMessage("");
                    return s.Create();
            }

            return null;
        }
        private void ShowMessage(string messageBoxText, string caption, MessageButton button, MessageImage icon,
            MessageResult defaultResult,
            TaskCompletionSource<MessageResult> tcs)
        {
#if XAMARIN_FORMS
            var activity = global::Xamarin.Forms.Forms.Context;
#else
            var activity = PlatformExtensions.CurrentActivity as IActivityView;
#endif
            Should.BeSupported(activity != null, "The current top activity is null.");
            AlertDialog.Builder builder = new AlertDialog.Builder((Context)activity)
                .SetTitle(caption)
                .SetMessage(messageBoxText)
                .SetCancelable(false);
            switch (button)
            {
                case MessageButton.Ok:
                    builder.SetPositiveButton(GetButtonText(MessageResult.Ok),
                        (sender, args) => tcs.TrySetResult(MessageResult.Ok));
                    break;
                case MessageButton.OkCancel:
                    builder.SetPositiveButton(GetButtonText(MessageResult.Ok),
                        (sender, args) => tcs.TrySetResult(MessageResult.Ok));
                    builder.SetNegativeButton(GetButtonText(MessageResult.Cancel),
                        (sender, args) => tcs.TrySetResult(MessageResult.Cancel));
                    break;
                case MessageButton.YesNo:
                    builder.SetPositiveButton(GetButtonText(MessageResult.Yes),
                        (sender, args) => tcs.TrySetResult(MessageResult.Yes));
                    builder.SetNegativeButton(GetButtonText(MessageResult.No),
                        (sender, args) => tcs.TrySetResult(MessageResult.No));
                    break;
                case MessageButton.YesNoCancel:
                    builder.SetPositiveButton(GetButtonText(MessageResult.Yes),
                        (sender, args) => tcs.TrySetResult(MessageResult.Yes));
                    if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
                    {
                        builder.SetNegativeButton(GetButtonText(MessageResult.No),
                            (sender, args) => tcs.TrySetResult(MessageResult.No));
                        builder.SetNeutralButton(GetButtonText(MessageResult.Cancel),
                            (sender, args) => tcs.TrySetResult(MessageResult.Cancel));
                    }
                    else
                    {
                        builder.SetNeutralButton(GetButtonText(MessageResult.No),
                            (sender, args) => tcs.TrySetResult(MessageResult.No));
                        builder.SetNegativeButton(GetButtonText(MessageResult.Cancel),
                            (sender, args) => tcs.TrySetResult(MessageResult.Cancel));
                    }
                    break;
                case MessageButton.AbortRetryIgnore:
                    builder.SetPositiveButton(GetButtonText(MessageResult.Abort),
                        (sender, args) => tcs.TrySetResult(MessageResult.Abort));
                    builder.SetNeutralButton(GetButtonText(MessageResult.Retry),
                        (sender, args) => tcs.TrySetResult(MessageResult.Retry));
                    builder.SetNegativeButton(GetButtonText(MessageResult.Ignore),
                        (sender, args) => tcs.TrySetResult(MessageResult.Ignore));
                    break;
                case MessageButton.RetryCancel:
                    builder.SetPositiveButton(GetButtonText(MessageResult.Retry),
                        (sender, args) => tcs.TrySetResult(MessageResult.Retry));
                    builder.SetNegativeButton(GetButtonText(MessageResult.Cancel),
                        (sender, args) => tcs.TrySetResult(MessageResult.Cancel));
                    break;
                default:
                    throw new ArgumentOutOfRangeException("button");
            }
            int? drawable = GetIconResource(icon);
            if (drawable != null)
                builder.SetIcon(drawable.Value);
            AlertDialog dialog = builder.Create();
#if !XAMARIN_FORMS
            EventHandler<Activity, EventArgs> handler = null;
            handler = (sender, args) =>
            {
                ((IActivityView)sender).Mediator.Destroyed -= handler;
                tcs.TrySetResult(defaultResult);
            };
            activity.Mediator.Destroyed += handler;
#endif
            dialog.Show();
        }
		private void SetupBluetooth(){
			if(!MonoBrick.Bluetooth<BrickCommand,BrickReply>.IsEnabled){
				//Intent enableBtIntent = new Intent(BluetoothAdapter.ActionRequestEnable);
				//StartActivityForResult(enableBtIntent,(int) ActivityResult.BluetoothEnabled);
				AlertDialog.Builder dialog = new AlertDialog.Builder(new ContextThemeWrapper(this, Android.Resource.Style.ThemeTranslucentNoTitleBar));
				//AlertDialog	dialog = new  AlertDialog.Builder(this).Create();
				dialog.SetIcon(Android.Resource.Drawable.IcDialogInfo);
				dialog.SetTitle("Bluetooth permission request");
				dialog.SetMessage("This application is requesting permission to turn on Bluetooth");

				dialog.SetPositiveButton("Yes",delegate(object sender, DialogClickEventArgs e){	ProgressDialog progress = ProgressDialog.Show(this,"","Turning on Bluetooth...");
					Thread t = new Thread(
						new ThreadStart(
						delegate()
						{
						MonoBrick.Bluetooth<BrickCommand,BrickReply>.Enable();
							Stopwatch stopWatch = new Stopwatch();
							stopWatch.Start();
							while(!MonoBrick.Bluetooth<BrickCommand,BrickReply>.IsEnabled && stopWatch.ElapsedMilliseconds < 5000){}
							stopWatch.Stop();
							progress.Dismiss();
							if(!MonoBrick.Bluetooth<BrickCommand,BrickReply>.IsEnabled){
								RunOnUiThread(delegate() {
									ShowToast("Failed to turn on Bluetooth");
									//Update GUI
								});
						}
					}));
					t.IsBackground = true;
					t.Priority =  System.Threading.ThreadPriority.Normal;
					t.Start();
				});
				dialog.Show();
			}
			else{
				//Update GUI
			}
		}
		void HandleItemClick (object sender, AdapterView.ItemClickEventArgs e)
		{
			var item = adapter [e.Position];

			var alert = new AlertDialog.Builder (this);
			alert.SetIcon (Resource.Drawable.ic_launcher);
			alert.SetTitle (Resource.String.steps_cap);
			var view = LayoutInflater.Inflate (Resource.Layout.step_entry, null);
			var stepsEdit = view.FindViewById<EditText> (Resource.Id.step_count);

			stepsEdit.Text = item.Steps.ToString ();
			alert.SetView (view);

			alert.SetPositiveButton (Resource.String.ok, (object sender2, DialogClickEventArgs e2) => {

				//so now we want to see where we were previously, and where they 
				//want to set it. We will update the database entry,
				//update total steps in settings, and action bar title
				//which will also invalidate our share options!
				//if they set it to a negative number do not allow it.

				var newCount = -1;
				if (!Int32.TryParse (stepsEdit.Text, out newCount))
					return;

				if (newCount < 0)
					return;

				var diff = newCount - item.Steps;

				//update total steps even if negative as it will never go to 0
				//also update steps before today so home screen is correct and doesn't change
				Settings.TotalSteps += diff;
				Settings.StepsBeforeToday += diff;

				if (spinnerAdapter != null) {
					var last7 = DateTime.Today.AddDays (-6);
					var last30 = DateTime.Today.AddDays (-30);
					if (item.Date >= last7) {
						weekSteps += diff;
						monthSteps += diff;
					} else if (item.Date >= last30) {
						monthSteps += diff;
					}

				}

				item.Steps = newCount;

				Database.StepEntryManager.SaveStepEntry (item);

				//update UI
				RunOnUiThread (() => {
					adapter.NotifyDataSetChanged ();
					SetActionBar ();
				});
			});

			//we are lucky here as cancel is translated by android :)
			alert.SetNegativeButton (Android.Resource.String.Cancel, delegate {
				//do nothing here.
			});

			alert.Show ();
		}
        private static void ShowPopUp(Context context, string message)
        {
            try
            {
                AlertDialog.Builder alert = new AlertDialog.Builder(MainActivity.CurrentActivity);

                alert.SetTitle("Doctor Notification");
                alert.SetMessage(message);
                alert.SetIcon(Resource.Drawable.ic_launcher);
                alert.SetPositiveButton("Good", (senderAlert, args) => { });

                //run the alert in UI thread to display in the screen
                MainActivity.CurrentActivity.RunOnUiThread(() => { alert.Show(); });
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(
                    string.Format("Error occurred in the notification: {0}.", ex.Message));
            }
        }
示例#29
0
        private void ConfirCompra()
        {
            AlertDialog.Builder builder = new AlertDialog.Builder (this.Activity);

            builder.SetTitle ("Comprar");
            builder.SetIcon (Resource.Drawable.ic_stat_checka);
            builder.SetMessage("¿Esta seguro de hacer la compra?");
            builder.SetCancelable (false);
            builder.SetPositiveButton ("Si",  delegate {

                this.Activity.SupportFragmentManager.BeginTransaction ()
                    .Replace (Resource.Id.content_frame,
                        InfCMFragment.NewInstance (), "InfCMFragment")
                    .AddToBackStack ("InitFragment")
                    .Commit ();

            });

            builder.SetNegativeButton ("Cancel", delegate {

            });

            builder.Show ();
        }
        protected override Dialog OnCreateDialog(int id)
        {
            switch (id) {
                case DIALOG_YES_NO_MESSAGE: {
                        var builder = new AlertDialog.Builder (this);
                        builder.SetIconAttribute (Android.Resource.Attribute.AlertDialogIcon);
                        builder.SetTitle (Resource.String.alert_dialog_two_buttons_title);
                        builder.SetPositiveButton (Resource.String.alert_dialog_ok, OkClicked);
                        builder.SetNegativeButton (Resource.String.alert_dialog_cancel, CancelClicked);

                        return builder.Create ();
                    }
                case DIALOG_YES_NO_OLD_SCHOOL_MESSAGE: {
                        var builder = new AlertDialog.Builder (this, Android.App.AlertDialog.ThemeTraditional);
                        builder.SetIconAttribute (Android.Resource.Attribute.AlertDialogIcon);
                        builder.SetTitle (Resource.String.alert_dialog_two_buttons_title);
                        builder.SetPositiveButton (Resource.String.alert_dialog_ok, OkClicked);
                        builder.SetNegativeButton (Resource.String.alert_dialog_cancel, CancelClicked);

                        return builder.Create ();
                    }
                case DIALOG_YES_NO_HOLO_LIGHT_MESSAGE: {
                        var builder = new AlertDialog.Builder (this, Android.App.AlertDialog.ThemeHoloLight);
                        builder.SetIconAttribute (Android.Resource.Attribute.AlertDialogIcon);
                        builder.SetTitle (Resource.String.alert_dialog_two_buttons_title);
                        builder.SetPositiveButton (Resource.String.alert_dialog_ok, OkClicked);
                        builder.SetNegativeButton (Resource.String.alert_dialog_cancel, CancelClicked);

                        return builder.Create ();
                    }
                case DIALOG_YES_NO_LONG_MESSAGE: {
                        var builder = new AlertDialog.Builder (this);
                        builder.SetIconAttribute (Android.Resource.Attribute.AlertDialogIcon);
                        builder.SetTitle (Resource.String.alert_dialog_two_buttons_msg);
                        builder.SetMessage (Resource.String.alert_dialog_two_buttons_msg);
                        builder.SetPositiveButton (Resource.String.alert_dialog_ok, OkClicked);
                        builder.SetNegativeButton (Resource.String.alert_dialog_cancel, CancelClicked);
                        builder.SetNeutralButton (Resource.String.alert_dialog_something, NeutralClicked);

                        return builder.Create ();
                    }
                case DIALOG_YES_NO_ULTRA_LONG_MESSAGE: {
                        var builder = new AlertDialog.Builder (this);
                        builder.SetIconAttribute (Android.Resource.Attribute.AlertDialogIcon);
                        builder.SetTitle (Resource.String.alert_dialog_two_buttons_msg);
                        builder.SetMessage (Resource.String.alert_dialog_two_buttons2ultra_msg);
                        builder.SetPositiveButton (Resource.String.alert_dialog_ok, OkClicked);
                        builder.SetNegativeButton (Resource.String.alert_dialog_cancel, CancelClicked);
                        builder.SetNeutralButton (Resource.String.alert_dialog_something, NeutralClicked);

                        return builder.Create ();
                    }
                case DIALOG_LIST: {
                        var builder = new AlertDialog.Builder (this);
                        builder.SetTitle (Resource.String.select_dialog);
                        builder.SetItems (Resource.Array.select_dialog_items, ListClicked);

                        return builder.Create ();
                    }
                case DIALOG_PROGRESS: {
                        progress_dialog = new ProgressDialog (this);
                        progress_dialog.SetIconAttribute (Android.Resource.Attribute.AlertDialogIcon);
                        progress_dialog.SetTitle (Resource.String.select_dialog);
                        progress_dialog.SetProgressStyle (ProgressDialogStyle.Horizontal);
                        progress_dialog.Max = MAX_PROGRESS;

                        progress_dialog.SetButton (Android.App.Dialog.InterfaceConsts.ButtonPositive, GetText (Resource.String.alert_dialog_ok), OkClicked);
                        progress_dialog.SetButton (Android.App.Dialog.InterfaceConsts.ButtonNegative, GetText (Resource.String.alert_dialog_cancel), CancelClicked);

                        return progress_dialog;
                    }
                case DIALOG_SINGLE_CHOICE: {
                        var builder = new AlertDialog.Builder (this);
                        builder.SetIconAttribute (Android.Resource.Attribute.AlertDialogIcon);
                        builder.SetTitle (Resource.String.alert_dialog_single_choice);
                        builder.SetSingleChoiceItems (Resource.Array.select_dialog_items2, 0, ListClicked);

                        builder.SetPositiveButton (Resource.String.alert_dialog_ok, OkClicked);
                        builder.SetNegativeButton (Resource.String.alert_dialog_cancel, CancelClicked);

                        return builder.Create ();
                    }
                case DIALOG_MULTIPLE_CHOICE: {
                        var builder = new AlertDialog.Builder (this);
                        builder.SetIcon (Resource.Drawable.ic_popup_reminder);
                        builder.SetTitle (Resource.String.alert_dialog_multi_choice);
                        builder.SetMultiChoiceItems (Resource.Array.select_dialog_items3, new bool[] { false, true, false, true, false, false, false }, MultiListClicked);

                        builder.SetPositiveButton (Resource.String.alert_dialog_ok, OkClicked);
                        builder.SetNegativeButton (Resource.String.alert_dialog_cancel, CancelClicked);

                        return builder.Create ();
                    }
                case DIALOG_MULTIPLE_CHOICE_CURSOR: {
                        var projection = new string[] { BaseColumns.Id, Contacts.PeopleColumns.DisplayName, Contacts.PeopleColumns.SendToVoicemail };
                        var cursor = ManagedQuery (ContactsContract.Contacts.ContentUri, projection, null, null, null);

                        var builder = new AlertDialog.Builder (this);
                        builder.SetIcon (Resource.Drawable.ic_popup_reminder);
                        builder.SetTitle (Resource.String.alert_dialog_multi_choice_cursor);
                        builder.SetMultiChoiceItems (cursor, Contacts.PeopleColumns.SendToVoicemail, Contacts.PeopleColumns.DisplayName, MultiListClicked);

                        return builder.Create ();
                    }
                case DIALOG_TEXT_ENTRY: {
                        // This example shows how to add a custom layout to an AlertDialog
                        var factory = LayoutInflater.From (this);
                        var text_entry_view = factory.Inflate (Resource.Layout.alert_dialog_text_entry, null);

                        var builder = new AlertDialog.Builder (this);
                        builder.SetIconAttribute (Android.Resource.Attribute.AlertDialogIcon);
                        builder.SetTitle (Resource.String.alert_dialog_text_entry);
                        builder.SetView (text_entry_view);
                        builder.SetPositiveButton (Resource.String.alert_dialog_ok, OkClicked);
                        builder.SetNegativeButton (Resource.String.alert_dialog_cancel, CancelClicked);

                        return builder.Create ();
                    }
            }
            return null;
        }