Пример #1
0
        public override void CreateView()
        {
            _view = new EditTextNative(Activity);
            _view.SetSelectAllOnFocus(true);
            _view.Text         = _text;
            _view.Gravity      = GravityFlags.Top;
            _view.FocusChange += View_FocusChange;
            _view.TextChanged += EditText_TextChanged;
            _view.Hint         = _placeholder;
            _view.Enabled      = _enabled;

            InputTypes inputType;

            switch (Keyboard.ToLower())
            {
            case KeyboardAuto:
                if (Value != null && Value.IsNumeric())
                {
                    inputType = InputTypes.NumberFlagSigned | InputTypes.NumberFlagDecimal;
                    _inputValidator.IsNumeric = true;
                }
                else
                {
                    inputType = InputTypes.ClassText;
                }
                break;

            case KeyboardDefault:
                inputType = InputTypes.ClassText;
                break;

            case KeyboardNumeric:
                inputType = InputTypes.ClassNumber | InputTypes.NumberFlagSigned | InputTypes.NumberFlagDecimal;
                _inputValidator.IsNumeric = true;
                break;

            case KeyboardEmail:
                inputType = InputTypes.ClassText | InputTypes.TextVariationEmailAddress;
                break;

            case KeyboardUrl:
                inputType = InputTypes.ClassText | InputTypes.TextVariationUri;
                break;

            case KeyboardPhone:
                inputType = InputTypes.ClassPhone;
                break;

            default:
                inputType = InputTypes.ClassText;
                break;
            }

            if (IsMultiline())
            {
                inputType |= InputTypes.TextFlagMultiLine;
            }
            _view.SetRawInputType(inputType);
        }
Пример #2
0
        public override View CreateView()
        {
            _view = new EditTextNative(_activity);
            _view.SetSelectAllOnFocus(true);
            _view.Text         = _text;
            _view.Gravity      = GravityFlags.Top;
            _view.FocusChange += View_FocusChange;
            _view.TextChanged += EditText_TextChanged;
            _view.Hint         = _placeholder;

            switch (Keyboard.ToLower())
            {
            case KeyboardAuto:
                if (Value != null && Value.IsNumeric())
                {
                    _view.InputType = InputTypes.ClassNumber | InputTypes.NumberFlagDecimal;
                }
                else
                {
                    _view.InputType = InputTypes.ClassText;
                }
                break;

            case KeyboardDefault:
                _view.InputType = InputTypes.ClassText;
                break;

            case KeyboardNumeric:
                _view.InputType = InputTypes.ClassNumber | InputTypes.NumberFlagSigned | InputTypes.NumberFlagDecimal;
                break;

            case KeyboardEmail:
                _view.InputType = InputTypes.ClassText | InputTypes.TextVariationEmailAddress;
                break;

            case KeyboardUrl:
                _view.InputType = InputTypes.ClassText | InputTypes.TextVariationUri;
                break;

            default:
                _view.InputType = InputTypes.ClassText;
                break;
            }

            return(_view);
        }