public void Show(Context context)
        {
            var adb = new IONAlertDialog(context);

            var view  = LayoutInflater.From(context).Inflate(Resource.Layout.dialog_rename, null, false);
            var entry = view.FindViewById <EditText>(Resource.Id.name);

            entry.Hint = renamable.defaultName;
            entry.Text = renamable.name;

            adb.SetTitle(Resource.String.rename);
            adb.SetMessage(renamable.GetRenameMessage(context));
            adb.SetView(view);

            adb.SetNegativeButton(Resource.String.cancel, (obj, e) => {
                var dialog = obj as Dialog;
                dialog.Dismiss();
            });

            adb.SetPositiveButton(Resource.String.ok_done, (obj, e) => {
                var dialog = obj as Dialog;
                dialog.Dismiss();

                if (string.IsNullOrEmpty(entry.Text.Trim()))
                {
                    renamable.name = renamable.defaultName;
                }
                else
                {
                    renamable.name = entry.Text;
                }
            });

            adb.Show();
        }
示例#2
0
        /// <summary>
        /// Shows the dialog.
        /// </summary>
        /// <param name="context">Context.</param>
        public AlertDialog Show(Context context)
        {
            var adb = new IONAlertDialog(context);

            adb.SetTitle(title);
            adb.SetMessage(message);

            var entry = new EditText(context);

            entry.Hint      = hint;
            entry.Text      = initialValue + "";
            entry.InputType = Android.Text.InputTypes.NumberFlagDecimal;

            adb.SetView(entry);

            AlertDialog ret = null;

            adb.SetNegativeButton(context.GetString(Resource.String.cancel), (obj, args) => {
                var dialog = obj as Android.App.Dialog;
                dialog.Dismiss();
            });

            adb.SetPositiveButton(context.GetString(Resource.String.ok_done), (obj, args) => {
                var dialog = obj as Android.App.Dialog;

                try {
                    if (string.IsNullOrEmpty(entry.Text))
                    {
                        handler(ret, 0);
                    }
                    else
                    {
                        var number = double.Parse(entry.Text);
                        if (handler != null)
                        {
                            handler(ret, number);
                        }
                    }
                    dialog.Dismiss();
                } catch (Exception) {
                    Toast.MakeText(context, Resource.String.please_enter_valid_number, ToastLength.Long).Show();
                }
            });

            ret = adb.Create();

            ret.Show();
            return(ret);
        }
示例#3
0
        public static Dialog ShowDialog(Context context, string title, string message, Action positive, Action negative = null)
        {
            var adb = new IONAlertDialog(context, title);

            adb.SetMessage(message);

            adb.SetNegativeButton(Resource.String.cancel, (sender, e) => {
                (sender as Dialog).Dismiss();
                if (negative != null)
                {
                    negative();
                }
            });

            adb.SetPositiveButton(Resource.String.ok, (sender, e) => {
                (sender as Dialog).Dismiss();
                positive();
            });

            return(adb.Show());
        }