2014-09-26 63 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將改進對圖像顯示的支持,以便將來可以添加該功能。

相關問題