简体   繁体   English

Android-数字(浮点)软键盘

[英]Android - Numeric (float) soft keyboard

I need to insert in an EditText some numeric data with decimal. 我需要在EditText中插入一些带有小数的数字数据。 I know that i could insert this: 我知道我可以插入:

android:inputType="numberDecimal"

in my xml file. 在我的xml文件中。 But I'd like a different keyboard with only numeric (and point) keys. 但是我想要一个只带有数字(和点)键的键盘。 Something like the "phone" keyboard ( android:inputType="phone" ). 类似于“电话”键盘( android:inputType="phone" )。

I know, this is a duplicated question ( here the original) but i decided to open a new one because the first one doesn't look to have a good solution. 我知道,这是一个重复的问题( 这里是原始问题),但我决定打开一个新问题,因为第一个问题看起来并没有一个好的解决方案。

It depends on keyboard app, which is installed on your device, which buttons are visible for different inputTypes. 这取决于设备上安装的键盘应用程序,不同的inputTypes可以看到哪些按钮。 You can't simply override default keyboard due to security issues. 由于安全问题,您不能简单地覆盖默认键盘。 But you can create your own implementation. 但是您可以创建自己的实现。 But it needs to be registered by user in settings. 但是它需要由用户在设置中注册。

There is how to do it: 有做的方法:
http://android-developers.blogspot.com/2009/04/creating-input-method.html http://android-developers.blogspot.com/2009/04/creating-input-method.html

And sample keyboard: 和示例键盘:
http://developer.android.com/resources/samples/SoftKeyboard/index.html http://developer.android.com/resources/samples/SoftKeyboard/index.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM