2

我有一个 GWT 应用程序,它的目标是在移动设备上运行。我想使用新的 HTML5input type="tel"来接受电话输入并让移动设备提示输入正确的键盘输入(数字)。

我正在尝试使用 GWT 文本框,但看不到让它以正确的输入类型呈现 HTML 的方法。

关于这个有什么想法吗?

提前致谢。

4

3 回答 3

5

简单的方法

TextBox tel=new TextBox();
tel.getElement().setAttribute("type", "tel");

TextBox email=new TextBox();
email.getElement().setAttribute("type", "email");

TextBox url=new TextBox();
url.getElement().setAttribute("type", "url");
于 2012-07-19T07:08:30.883 回答
2

创建自定义小部件:

package com.example;

import com.google.gwt.dom.client.InputElement;
import com.google.gwt.user.client.ui.TextBoxBase;

public class TelephoneBox extends TextBoxBase {

    public TelephoneBox() {
        super(createTelInput());
    }

    private static native InputElement createTelInput() /*-{
        var input = document.createElement("input");
        input.setAttribute("type", "tel");
        return input;
    }-*/;
}

然后就可以在 UiBinder 中使用了:

<ui:UiBinder ... xmlns:my="urn:import:com.example">
...
<my:TelephoneBox/>
于 2013-03-17T13:20:30.553 回答
0

mgwt ( http://www.m-gwt.com )中有很多不同的输入(也是电话输入),它是移动设备的 GWT。你可能想看看它。

于 2012-07-19T06:09:33.517 回答