我需要在应用程序中显示动画 gif 图像。在以下代码示例中,我设置了 Label 小部件的 setImage 属性。这在浏览器(说唱)中运行良好,但移动应用程序仅显示没有动画的静态图像。有没有办法使用 Tabris 框架显示动画图像?
private void openDialog() {
this.display = getUI().getDisplay();
this.shell = new Shell( this.display, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL );
this.shell.setLayout( new GridLayout() );
Image image = createImage( this.display, "resources/loading.gif" );
Label label = new Label( this.shell, SWT.NONE );
label.setImage( image );
this.shell.open();
}
private Image createImage( Display display, String resourceName ) {
ClassLoader classLoader = getClass().getClassLoader();
InputStream inputStream = classLoader.getResourceAsStream( resourceName );
if( inputStream == null ) {
throw new IllegalArgumentException( "Resource not found: " + resourceName );
}
try {
return new Image( display, inputStream );
} finally {
try {
inputStream.close();
} catch( IOException exception ) {
// TODO handle exception
}
}
}