[英]EditText with numeric keyboard but allowing alphanumeric values
Problem: 问题:
a method within that class called " setInputType()
" with this.getEditText().setRawInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED);
该类中的一个方法叫做“
setInputType()
与this.getEditText().setRawInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED);
my xml with elements of my own EditText-class with 我的xml具有我自己的EditText-class的元素,具有
android:digits="1234567890"
What i want is: 我想要的是:
my problem: 我的问题:
I can type the numbers from 0123456789
, but my edittext opens with the normal keyboard. 我可以输入
0123456789
的数字,但是我的edittext用普通键盘打开。 but when I tried to change it to numeric keyboard, I couldnt manage to make the 0 be allowed. 但是,当我尝试将其更改为数字键盘时,我无法设法将其设置为0。 Is there a clean solution?
有没有干净的解决方案? everything i found is either just making the numeric keyboard as default OR allowing my wanted digits.
我发现的所有内容要么只是将数字键盘设置为默认键盘,要么允许我想要的数字。
Thank you for your help :) 谢谢您的帮助 :)
Change XML's Edit text with simply this :: 只需使用以下::更改XML的编辑文本:
<EditText
android:id="@+id/edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLength="50"
android:singleLine="true"
/>
And code as :: 和代码为::
editText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_NORMAL);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.