[英]Android: Set alphanumeric keyboard to show numeric first in EditText
I'm implementing an Android App and I need a tip. 我正在实施一个Android应用程序,我需要一个提示。 My
EditText
, usually, is just numbers, but sometimes numbers and letters. 我的
EditText
通常只是数字,但有时是数字和字母。
This is the keyboard that I need as "default", when the EditText
is focused: 当
EditText
聚焦时,这是我需要的键盘“默认”:
If I put android:inputType="phone"
or android:inputType="number"
, the result isn't what I need: 如果我把
android:inputType="phone"
或android:inputType="number"
,结果不是我需要的:
I need numbers and letters. 我需要数字和字母。 So, is it possible to do?
那么,有可能吗? I already tried EVERY
inputType
. 我已经尝试了每个
inputType
。 I try to "mix" some inputType
s, like, number | text
我尝试“混合”一些
inputType
s,比如, number | text
number | text
, but nothing changes. number | text
,但没有任何变化。
If you want a general keyboard you can use this: 如果你想要一般的键盘,你可以使用它:
android:inputType="text"
This will allow you to use default keyboard with all the special characters, numerics and alphabets one needs. 这将允许您使用默认键盘,其中包含所需的所有特殊字符,数字和字母。
Looking at the date when this question was asked no doubt it was a hassle to feed the type of keyboard desired. 看一下提出这个问题的日期,毫无疑问,提供所需的键盘类型是一件麻烦事。 Anyways, if you are still tracking this question.
无论如何,如果你仍在追踪这个问题。 Here's the answer.
这是答案。
<EditText android:inputType="number" ... />
Above code must need 1.5 or up version if its not working also try 上面的代码必须需要1.5或更高版本,如果它不工作也尝试
EditText num = new EditText(this);
num.setInputType(InputType.TYPE_CLASS_NUMBER);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.