java Android inputType="numberDecimal" 调出没有逗号的键盘

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11921610/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 06:57:12  来源:igfitidea点击:

Android inputType="numberDecimal" brings up keyboard without commas

javaandroid

提问by Tobias Jessen

So i have been playing around with a little game with some mathematical questions. The application gives you, for example, a question like 23 + 47, and that's fine and all, but when it gives you a question like 9/6 the problems appears. Since you input the result in an EditText, i need the correct input type. But! when i do

所以我一直在玩一些数学问题的小游戏。例如,该应用程序给您一个类似 23 + 47 的问题,这很好,但是当它给您一个类似 9/6 的问题时,问题就会出现。由于您在 EditText 中输入结果,因此我需要正确的输入类型。但!当我做

android:inputType="numberDecimal"

the soft keyboard it comes up with, is a soft keyboard without seperators, which mean i can't make commas. And it pretty much ruins the game :-) I have tried things like

它带来的软键盘,是一个没有分隔符的软键盘,这意味着我不能做逗号。它几乎毁了游戏:-)我尝试过类似的东西

android:inputType"numberSigned|numberDecimal"

android:inputType"numberSigned|numberDecimal"

i have also tried

我也试过

android:digits="0123456789."but nothing worked so far.

android:digits="0123456789."但到目前为止没有任何效果。

I just can't get the right keyboard up.

我就是无法调出正确的键盘。

Any suggestions?

有什么建议?

采纳答案by Chandra Sekhar

android:inputType="numberDecimal"

is for taking decimal inputs, so all the digits from 0 to 9 including the decimal point sign(.) only can be the input values. And it works fine. I don't understand where comma sign came into picture.

用于取十进制输入,因此从0到9的所有数字包括小数点符号(.)只能作为输入值。它工作正常。我不明白逗号符号是从哪里出现的。

回答by Lay Leangsros

Try add comma ",". It may cause from different format of digits.

尝试添加逗号“,”。这可能是由不同格式的数字引起的。

<EditText
    android:inputType="number"
    android:digits="0123456789.," />