我试图使用gwt的uiBinder来获取图像,但它不会起作用,
在.xml文件中,我定义了:
<ui:with field='res' type="com.my.services.email.client.Resources"/>
<ui:image field="testImage" resource="{res.calIcon}">
我有一个Resources.java文件来定义图像资源:
public interface Resources extends ClientBundle {
Resources INSTANCE = GWT.create(Resources.class);
@Source("img/cal.png")
ImageResource calIcon();
}
和gwt抱怨:
[ERROR] No com.google.gwt.resources.client.ClientBundle$Source annotation and no resources found with default extensions
谁知道这有什么问题?谢谢!
我遇到了同样的问题,经过多次阅读和尝试,我发现不需要声明图像标签来访问图像,一旦声明就<ui:with field='res' type="com.my.services.email.client.Resources"/>可以直接检索图像。
这是我的代码,我使用了两个图像作为按钮
<ui:with field='res' type='com.ttt.client.resources.ImageResources'/>
...
<g:PushButton ui:field='r0Button'>
<g:upFace image='{res.icoStatusR0}'>R0</g:upFace>
<g:downFace image='{res.icoStatusR0pushed}'>R0</g:downFace>
</g:PushButton>
...
Run Code Online (Sandbox Code Playgroud)
对于资源文件,请确保图像的路径正确。我使用向导来生成我的,所以我确信路径是正确的。