ANDROID - 数字键盘数字键盘、ANDROID

2023-09-06 16:47:23 作者:凝眸、

下午好。

我有可能包含数字和字母一个EditText。通过部署键盘,有没有什么办法可以以数字形式部署呢?

I have an EditText that may contain numbers and letters. By deploying the keyboard, is there any way to deploy it in numerical form?.

如果我把这个作为的EditText数字我这样做,但这不是我的情况。

If I put the EditText as numeric I do, but that's not my case.

非常感谢你。

推荐答案

试试这个:

EditText myEditText = (EditText)findViewById(R.id.myEditText);
myEditText.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL);

然后将其设置回字母,当你用数字做了。

Then set it back to alphanumeric when you are done with numeric..