我怎么默认为上的EditText数字键盘而不强制数字输入?而不、为上、我怎么、数字

由网友(乐原)分享简介:这已在别处要求在线无济于事。有没有办法在Android的重点放在了的EditText ,但仍允许输入任何文字时显示的数字软键盘? This has been asked elsewhere online to no avail. Is there any way in Android to display the n...

这已在别处要求在线无济于事。有没有办法在Android的重点放在了的EditText ,但仍允许输入任何文字时显示的数字软键盘?

This has been asked elsewhere online to no avail. Is there any way in Android to display the numeric soft keyboard when focusing on an EditText, but still allow any text to be entered?

我想,让用户输入量(如1公斤,2升),所以只设置 inputType =号不会的工作。

I'd like to let the user enter quantities (e.g. "1 kg", "2 L"), so just setting inputType="number" won't work.

推荐答案

加code以下行,它会做的伎俩:)

Add the following line of code, and it will do the trick :)

editText.setRawInputType(Configuration.KEYBOARD_QWERTY);

这将首先显示的数字小键盘,而且还可以让你输入自由文本。

This will show the the numeric keypad first, but also allows you to enter free text.

这里更多信息。

More information here.

阅读全文

相关推荐

最新文章