Áxe*_*ena 7 html5 android android-softkeyboard galaxy-tab
我知道有很多问题已经回复了,但是没有一个解决方案对我有用.
我正在为使用三星Galaxy Tab的企业开发一个网站.有很多输入,其内容是十进制数.所以我尝试了<input type="number" />.但是导航器会显示一个带点和逗号的键盘.不仅如此,还会从值中删除onfocus,点或逗号分隔符.
我已经尝试设置像"0,1","0,01","0.1","0.01","任何"等步骤,尝试使用匹配十进制数的正则表达式的min,max,pattern ...在stackoverflow中没有任何建议可以尝试,这是可怕的哈哈.
我使用三星Galaxy Tab 10.1和默认浏览器,但我没有找到任何文件谈论它的html5实现的任何限制.所以现在我不知道是否有我遗漏的东西,如果有什么我可以尝试,或者如果有什么东西知道这是Galaxy Tab的错,所以我无能为力.
非常感谢提前.
在android命名空间中,您可以使用:
android:inputType="numberDecimal"
Run Code Online (Sandbox Code Playgroud)
这使您可以输入"."
您需要扩展您的webview类并像这样使用其对象
public class WebViewExtended extends WebView{
public WebViewExtended(Context context) {
super(context);
}
public WebViewExtended(Context context, AttributeSet attrs) {
super(context, attrs);
}
public WebViewExtended(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
InputConnection connection = super.onCreateInputConnection(outAttrs);
if ((outAttrs.inputType & InputType.TYPE_CLASS_NUMBER) == InputType.TYPE_CLASS_NUMBER)
{
outAttrs.inputType |= InputType.TYPE_NUMBER_FLAG_DECIMAL;
}
return connection;
}
}
Run Code Online (Sandbox Code Playgroud)
针对数字类型输入的 HTML5 规范规定,应允许任何可解析为有效浮点数的字符串。具体包括.以及-、+和e。
因此在 Samsung Galaxy Tab 10.1 上的实现无效。
如果您需要支持此设备,您可能必须使用type="text"并验证该字符串。这不会在具有软件键盘的设备上自动弹出正确的键盘。
<input type="text" pattern="^-?(?:[0-9]+|[0-9]*\.[0-9]+)$" name="NumberInput">
Run Code Online (Sandbox Code Playgroud)