【问题标题】:how to add image in gwt uibinder如何在 gwt uibinder 中添加图像
【发布时间】:2014-08-31 11:52:01
【问题描述】:

我在 gwt 中有一个 UIBinder java 类,其中包含一个带有一些文本的标签,例如

 Label img = new Label();
 img.setText("<img src=h.png></img>") or some other Html tag like div

并在 HTMLPanel 中添加此标签

HTMLPanel html = new HTMLPanel;
html.add(img,"img");

现在我在 uibinder xml 中有一个表格,例如

 <table align="center" cellspacing="20px">
                        <tr>
                            <td>image</td>
                            <td id="image"></td>
                        </tr>
    <table>

但在这里我得到一个字符串

"<img src=h.png></img>"

不是图片,请有人帮助我..

【问题讨论】:

    标签: gwt


    【解决方案1】:

    如果您需要图像,则无需使用标签小部件。如果你使用 ImageResource,你可以这样做:

    // Link to your ClientBundle with ImageResource methods
    <ui:with type="com.myPackage.client.icons.Icons" field="icon" />
    
    <g:Image ui:field="myImage" resource="{icon.myImage}" />
    

    如果你不需要这张图片做任何事情,那么你可以简单地使用普通的 HTML:

    <g:HTMLPanel>
        <img src="h.png" />
    </g:HTMLPanel>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多