예제 #1
0
 protected virtual NumberKeyListener GetDigitsKeyListener(InputTypes inputTypes)
 {
     // Override this in a custom renderer to use a different NumberKeyListener
     // or to filter out input types you don't want to allow
     // (e.g., inputTypes &= ~InputTypes.NumberFlagSigned to disallow the sign)
     return(LocalizedDigitsKeyListener.Create(inputTypes));
 }
예제 #2
0
            void OnPromptRequested(Page sender, PromptArguments arguments)
            {
                // Verify that the page making the request is part of this activity
                if (!PageIsInThisContext(sender))
                {
                    return;
                }

                var alertDialog = new DialogBuilder(Activity).Create();

                alertDialog.SetTitle(arguments.Title);
                alertDialog.SetMessage(arguments.Message);

                var frameLayout = new FrameLayout(Activity);
                var editText    = new EditText(Activity)
                {
                    Hint = arguments.Placeholder, Text = arguments.InitialValue
                };
                var layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent)
                {
                    LeftMargin  = (int)(22 * Activity.Resources.DisplayMetrics.Density),
                    RightMargin = (int)(22 * Activity.Resources.DisplayMetrics.Density)
                };

                editText.LayoutParameters = layoutParams;
                editText.InputType        = arguments.Keyboard.ToInputType();
                if (arguments.Keyboard == Keyboard.Numeric)
                {
                    editText.KeyListener = LocalizedDigitsKeyListener.Create(editText.InputType);
                }

                if (arguments.MaxLength > -1)
                {
                    editText.SetFilters(new IInputFilter[] { new InputFilterLengthFilter(arguments.MaxLength) });
                }

                frameLayout.AddView(editText);
                alertDialog.SetView(frameLayout);

                alertDialog.SetButton((int)DialogButtonType.Positive, arguments.Accept, (o, args) => arguments.SetResult(editText.Text));
                alertDialog.SetButton((int)DialogButtonType.Negative, arguments.Cancel, (o, args) => arguments.SetResult(null));
                alertDialog.SetCancelEvent((o, args) => { arguments.SetResult(null); });

                alertDialog.Window.SetSoftInputMode(SoftInput.StateVisible);
                alertDialog.Show();
                editText.RequestFocus();
            }