如何以科学计数法启用用户输入到android edittext

时间:2015-11-11 19:12:22

标签: android scientific-notation

我想要一个以科学记数法接受数字的输入。如果您使用任何标准数字格式,科学记数法。例如

<EditText
   android:id="@+id/scientific_number" 
  android:inputType="number|numberSigned|numberDecimal" 
</EditText>

不起作用。用户无法输入科学记数法的指数部分(IE 1.00E-19)。

2 个答案:

答案 0 :(得分:0)

我知道你已经使用过这个,但只需要这一行在edittext中具有科学价值:

 android:inputType="numberDecimal"

检查链接:https://stackoverflow.com/questions/25479946/how-to-print-double-value-without-scientific-notation

Scientific notation android java

答案 1 :(得分:0)

似乎没有内置方法来显示带有额外“E”的数字键盘,这对于许多应用程序来说非常有用。

您有两种选择,一种是您可以设计自己的键盘,如下所述:

http://www.dreamincode.net/forums/index.php?automodule=blog&blogid=867&showentry=3460

其次,您可以放置​​一个按钮,将“E”放入编辑文本(我更喜欢这种方法)或将“E”放在光标处。这里描述了这样做的方法:

How allow a specific character in Android numerical keyboard?