【问题标题】:How to change the url of a g:image in gwt如何在 gwt 中更改 g:image 的 url
【发布时间】:2012-03-15 13:33:13
【问题描述】:

我是 GWT 的新手。 我在我的 ui.xml 中创建了一个包含图像的面板。 我想根据某些条件更改该图像的 url、alt 和标题。怎么办?

<g:Image url="images/document-statut-1.gif" title="My title" altText="My alt"></g:Image>

谢谢

【问题讨论】:

    标签: gwt uibinder


    【解决方案1】:

    修改 uibinder 元素,使其具有字段名称:

    <g:Image url="images/document-statut-1.gif" ui:field="imageWidget"
             title="My title" altText="My alt" />
    

    然后在你的java代码中创建一个匹配的字段:

    @UiField
    Image imageWidget;
    

    在您的 java 类中调用 createAndBind 方法后,您可以随时分配一个新的 url:

    imageWidget.setUrl("images/newStatus.gif");
    

    【讨论】:

    • 它正在工作,这就是我所做的,我忘了回答它:p Thnx。
    猜你喜欢
    • 2011-10-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多