【问题标题】:Android InputType password and InputType number not taking numbersAndroid InputType 密码和 InputType 数字不带数字
【发布时间】:2019-06-09 07:55:51
【问题描述】:

我正在使用 MaterialEditText 库。 虽然我尝试删除 MaterialEditText 库并使用普通的 EditText 也不起作用。

问题是当我尝试输入inputType="textPassword"inputType="number"inputType="numberDecimal" 时,我的editText 不会将数字作为输入。

我尝试了多部手机。我知道它在三星手机上正常工作,而在其他手机上却不行。

我错过了什么吗?

<com.rengwuxian.materialedittext.MaterialEditText
                android:id="@+id/mobile_number"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginEnd="@dimen/activity_horizontal_margin"
                android:layout_marginStart="@dimen/activity_horizontal_margin"
                android:hint="@string/mobile_number"
                android:inputType="numberDecimal"
                android:textSize="@dimen/font_size_sub_normal"
                app:met_clearButton="true"
                app:met_floatingLabel="normal"
                app:met_floatingLabelTextColor="@color/colorPrimary" />

即使我使用普通的editText,它也不起作用。

如果我删除 InputType 就可以了。

编辑: 我刚刚发现问题出在 Google 键盘上。三星键盘一切正常,但谷歌键盘的 inputType 不起作用。在不接受数字的意义上不起作用

【问题讨论】:

  • 您只需要输入数字吗?
  • 不仅仅是输入数字,问题在于 inputType
  • 您是否尝试过使用setTransformationMethod 方法以编程方式设置它?
  • 问题在于 inputType 如果我不使用它,一切似乎都是正确的。并且 inputType 适用于某些手机
  • 解决方案是什么?

标签: android key android-softkeyboard android-keypad


【解决方案1】:

尝试使用google提供的解决方案(支持库) EditText with TextInputlayout

【讨论】:

    猜你喜欢
    • 2012-04-10
    • 2016-01-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-09
    • 2011-10-13
    • 1970-01-01
    相关资源
    最近更新 更多