我怎么默认为上的EditText数字键盘而不强制数字输入? [英] How do I default to numeric keyboard on EditText without forcing numeric input?

查看:378
本文介绍了我怎么默认为上的EditText数字键盘而不强制数字输入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这已在别处要求在线无济于事。有没有办法在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.

这篇关于我怎么默认为上的EditText数字键盘而不强制数字输入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆