Пример #1
0
        protected override void UpdateDetailDisplay(View cell)
        {
            if (cell == null)
            {
                return;
            }

            TextView label;
            EditText _entry;

            DroidResources.DecodeStringEntryLayout(Context, cell, out label, out _entry);

            if (_entry == null)
            {
                return;
            }

            if (_entry.Text != Value)
            {
                _entry.Text = Value;
            }
            if (_entry.Hint != Hint)
            {
                _entry.Hint = Hint;
            }

            var inputType = KeyboardType.InputTypesFromUIKeyboardType();

            if (Password)
            {
                inputType |= InputTypes.TextVariationPassword;
            }

            if (IsEmail)
            {
                inputType |= AndroidDialogEnumHelper.KeyboardTypeMap[UIKeyboardType.EmailAddress];
            }

            if (Numeric)
            {
                inputType |= AndroidDialogEnumHelper.KeyboardTypeMap[UIKeyboardType.DecimalPad];
            }

            if (Lines > 1)
            {
                inputType |= InputTypes.TextFlagMultiLine;
                _entry.SetLines(Lines);
            }
            else if (Send != null)
            {
                _entry.ImeOptions = ImeAction.Go;
                _entry.SetImeActionLabel("Go", ImeAction.Go);
            }
            else
            {
                _entry.ImeOptions = ReturnKeyType.ImeActionFromUIReturnKeyType();
            }

            _entry.InputType = inputType;
        }
Пример #2
0
        protected override View GetViewImpl(Context context, ViewGroup parent)
        {
            var view = DroidResources.LoadStringEntryLayout(context, parent, LayoutName);

            if (view != null)
            {
                view.FocusableInTouchMode = false;
                view.Focusable            = false;

                TextView label;
                EditText _entry;
                DroidResources.DecodeStringEntryLayout(context, view, out label, out _entry);

                if (_entry != null)
                {
                    view.Clickable = Clickable;
                    view.Click    += (sender, args) => _entry.RequestFocus();

                    _entry.FocusableInTouchMode = true;
                    _entry.Focusable            = true;
                    _entry.Clickable            = Clickable;
                    var helper = EntryElementHelper.EnsureTagged(_entry);
                    helper.Owner = this;
                }
            }

            return(view);
        }
Пример #3
0
        protected override void UpdateCaptionDisplay(View cell)
        {
            if (cell == null)
            {
                return;
            }

            TextView label;
            EditText _entry;

            DroidResources.DecodeStringEntryLayout(Context, cell, out label, out _entry);

            if (label != null)
            {
                // note - Caption and Hint are no longer interchanged!
                label.Text = Caption;
            }
        }
Пример #4
0
        protected override void UpdateDetailDisplay(View cell)
        {
            if (cell == null)
            {
                return;
            }

            TextView label;
            EditText _entry;

            DroidResources.DecodeStringEntryLayout(Context, cell, out label, out _entry);

            if (_entry == null)
            {
                return;
            }

            if (_entry.Text != Value)
            {
                _entry.Text = Value;
            }
            if (_entry.Hint != Hint)
            {
                _entry.Hint = Hint;
            }

            var inputType = KeyboardType.InputTypesFromUIKeyboardType();

            if (Password)
            {
                inputType |= InputTypes.TextVariationPassword;
            }

            if (IsEmail)
            {
                inputType |= AndroidDialogEnumHelper.KeyboardTypeMap[UIKeyboardType.EmailAddress];
            }

            if (Numeric)
            {
                inputType |= AndroidDialogEnumHelper.KeyboardTypeMap[UIKeyboardType.DecimalPad];
            }

            if (NoAutoCorrect)
            {
                inputType |= AndroidDialogEnumHelper.KeyboardTypeMap[UIKeyboardType.NoAutoCorrect];
            }

            if (Lines > 1)
            {
                inputType |= InputTypes.TextFlagMultiLine;
                if (_entry.LineCount != Lines)
                {
                    _entry.SetLines(Lines);
                }
            }
            else if (Send != null)
            {
                if (_entry.ImeOptions != ImeAction.Go)
                {
                    _entry.ImeOptions = ImeAction.Go;
                    _entry.SetImeActionLabel("Go", ImeAction.Go);
                }
            }
            else
            {
                var imeOptions = ReturnKeyType.ImeActionFromUIReturnKeyType();
                if (_entry.ImeOptions != imeOptions)
                {
                    _entry.ImeOptions = imeOptions;
                }
            }
            if (_entry.InputType != inputType)
            {
                _entry.InputType = inputType;
            }

            //android can't seem to find the correct NextFocusDown if items are added dynamically, we'll catch the next/previous ourselves
            _entry.EditorAction += (sender, args) =>
            {
                if (args.ActionId == ImeAction.Next ||
                    (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Honeycomb &&
                     args.ActionId == ImeAction.Previous))
                {
                    ViewGroup   group       = _entry.Parent as ViewGroup;
                    IViewParent currentLoop = _entry.Parent;
                    while (currentLoop != null)
                    {
                        currentLoop = currentLoop.Parent;
                        if (currentLoop is ViewGroup)
                        {
                            group = (ViewGroup)currentLoop;
                        }
                    }
                    var focus = FocusFinder.Instance.FindNextFocus(group, _entry, args.ActionId == ImeAction.Next ? FocusSearchDirection.Down : FocusSearchDirection.Up);
                    if (focus != null)
                    {
                        focus.RequestFocus();
                        focus.RequestFocusFromTouch();
                    }
                }
            };
        }