2014-09-26 79 views
0

我需要在应用程序中显示动画gif图像。在下面的代码示例中,我设置了Label小部件的setImage属性。这在浏览器(说唱)中工作正常,但移动应用程序只显示静态图像,没有动画。有没有使用Tabris框架显示动画图像的方法?如何使用Tabris框架在SWT小部件中设置动画图像(gif)

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 
     } 
    } 
} 

回答

0

目前无法显示动画gif。 Tabris将改进对图像显示的支持,以便将来可以添加该功能。

相关问题