コード例 #1
0
        private static void SetupInputDialog(MaterialDialog dialog)
        {
            MaterialDialog.Builder builder = dialog.MBuilder;
            dialog.Input = dialog.GetView().FindViewById <EditText>(Android.Resource.Id.Input);
            if (dialog.Input == null)
            {
                return;
            }
            dialog.SetTypeface(dialog.Input, builder.RegularFont);
            if (builder.InputPrefill != null)
            {
                dialog.Input.Text = builder.InputPrefill;
            }
            dialog.SetInternalInputCallback();
            dialog.Input.Hint = builder.InputHint;
            dialog.Input.SetSingleLine();
            dialog.Input.SetTextColor(builder.ContentColor);
            dialog.Input.SetHintTextColor(DialogUtils.AdjustAlpha(builder.ContentColor, 0.3f));
            MDTintHelper.SetTint(dialog.Input, dialog.MBuilder.WidgetColor);

            if (builder.InputType != Android.Text.InputTypes.Null)
            {
                dialog.Input.InputType = builder.InputType;
                if ((builder.InputType & Android.Text.InputTypes.TextVariationPassword) == Android.Text.InputTypes.TextVariationPassword)
                {
                    dialog.Input.TransformationMethod = PasswordTransformationMethod.Instance;
                }
            }

            dialog.InputMinMax = dialog.GetView().FindViewById <TextView>(Resource.Id.minMax);
            if (builder.InputMaxLength > -1)
            {
                dialog.InvalidateInputMinMaxIndicator(dialog.Input.Text.Length,
                                                      !builder.InputAllowEmpty);
            }
            else
            {
                dialog.InputMinMax.Visibility = ViewStates.Gone;
                dialog.InputMinMax            = null;
            }
        }