Android 软键盘在输入类型 ="numberpassword"后显示 (A -Z) 文本 (1-9) 数字

标签 android android-softkeyboard

我有一个问题。

我正在努力寻找答案,但没有成功。

1-我有一个editpasswordfield,我只能在其中输入数字密码。

我喜欢这个

 <EditText
            android:id="@+id/editText4"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:inputType="numberPassword"/>

及其显示带有文本的键盘编号。 enter image description here

但我需要这样的键盘

enter image description here

我试过了

android:inputType="numberPassword|number"

还有很多可能性,但对我不起作用。

如果我尝试 android:inputType="number"。它可以工作,但我的字段是密码,所以这对用户不可见。

任何帮助。

最佳答案

试试这个..

 EditText editText = (EditText) findViewById(R.id.editText4);
    editText.setInputType(InputType.TYPE_CLASS_NUMBER);
    editText.setTransformationMethod(PasswordTransformationMethod.getInstance());

希望这对您有所帮助....

关于Android 软键盘在输入类型 ="numberpassword"后显示 (A -Z) 文本 (1-9) 数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16732436/

相关文章:

java - 单击 RadioButton 会使应用程序崩溃

android - 出于布局目的忽略 Android 软键盘

Android 软键盘错误消息

Android 显示超长滚动网页——这是不正确的行为

android - 改造 native 崩溃致命信号 11 (SIGSEGV)

java - 当您更改触摸位置时,为什么没有 reload() WebView

java - 第一次打开入职屏幕应该是 list 上的.LAUNCHER?

android - 避免通过虚拟键盘隐藏控件

android - 如何为 Android 应用程序开发自定义软键盘?