2011-06-18 77 views
0

事情是这样的。我有一个带有在后台解压缩的图像的zip文件(使用线程)我从我的主要文件开始一个新的活动来显示这些图像。为了表明我呼吁的onResume这个函数的第一个图像:吐司和图片未显示

public boolean showImage(String validFile){ 
    File page = new File(validFile); 
    System.err.println("Attempting to show " + validFile); 
    boolean found = false; 
    if (page.exists()){ 
     System.err.println("Page exist"); 
     found = true; 
    } 
    else{   
     System.err.println("Page does not exist"); 
     long start = System.currentTimeMillis(); 
     //ProgressDialog loading = ProgressDialog.show(this, "", "Loading....",true); 
     Toast.makeText(this, "Loading...", Toast.LENGTH_LONG); 
     while (((System.currentTimeMillis() - start) < 5000) && (!found)){    
      if (page.exists()){ 
       found = true; 
       //t.cancel(); 
       System.err.println("Page found"); 
      } 
      else{ 
       System.err.println("Page does not exist"); 
      } 
     } 
    }  
    if (!found){ 
     return false; 
    } 
    else{ 
     System.err.println("Setting up image"); 
     ims.setImageDrawable(new BitmapDrawable(BitmapFactory.decodeFile(validFile))); 
     return true; 
    }  
} 

所有我想要做的是显示敬酒,说加载进度对话框或东西...而第一图像进行解压。但是,无论是烤面包还是图像都不会显示。现在我知道该图像是有两个原因的:1设置图像和文件找到消息出现,我可以使用fling在图像中移动并且工作得很好。

这是发生了什么事。我的活动开始并输入上面的代码,但第一个图像从不显示。我扔掉,看到第二个图像和第三个图像等等。

那么我做错了什么?

感谢您的帮助!

+0

ü应添加.show()来显示你的吐司, – Houcine

回答

0

有可能是除此之外的另一个问题,但如果你不叫show()方法敬酒不会出现:

Toast.makeText(this, "Loading...", Toast.LENGTH_LONG).show(); 
+0

这的确让敬酒似乎非常感谢! – aarelovich