【问题标题】:How to get a pin number password keyboard in android?如何在 android 中获取 pin 号密码键盘?
【发布时间】:2012-10-15 17:22:11
【问题描述】:

我需要一个 PIN 码 EditText 上的数字键盘。我尝试使用

android:inputType="number|textPassword"

这会调出数字键盘,但字符不是密码字符。

如何获得在EditText 视图中显示密码字符的数字键盘?

该应用在 2.2 及更高版本上运行。

【问题讨论】:

  • @NathanVillaescusa 那里接受的答案没有帮助。这不是我的要求..我使用了另一个建议以编程方式设置类型的答案..

标签: android passwords numbers android-edittext


【解决方案1】:

你应该看看这里: Edittext set for password with phone number input? (android)

它指出 android:password 已弃用,但这是唯一的方法,因为 android:inputType="phone|textPassword" 被忽略...

<EditText
    android:id="@+id/EditText01"
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    android:password="true"
    android:inputType="phone" 
/>

【讨论】:

    【解决方案2】:

    在我的 styles.xml 中,这两个似乎对我有用:

    <item name="android:inputType">numberPassword</item>
    <item name="android:password">true</item>
    

    【讨论】:

      【解决方案3】:

      这行得通:

           <EditText
               android:id="@+id/pinEdit"
               android:layout_width="match_parent"
               android:layout_height="wrap_content"
               android:layout_margin="4dp"
               android:digits="1234567890"
               android:inputType="textPassword"
               android:maxLength="4" >
      
               <requestFocus />
           </EditText>
      

      如果数字对你有用。

      编辑:啊,我明白了,它没有调出数字键盘……回到绘图板。

      【讨论】:

      • android:inputType="numberPassword" 用于数字键盘
      【解决方案4】:

      使用:"numberSigned|numberPassword"

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-06-19
        • 1970-01-01
        • 1970-01-01
        • 2018-12-17
        相关资源
        最近更新 更多