2013-03-22 29 views

回答

1

希望AQuery庫是你在找什麼,便於圖像加載上ImageView

0

嘗試這個

Drawable drawable = LoadImage(<Replace this with your url> + UserProfile.Photo); 
UserPhotoImageView.setImageDrawable(drawable); 
<replace with Your Image View>.setImageDrawable(drawable); 


public Drawable LoadImage(String url) 
    { 
     try 
     { 
      InputStream is = (InputStream) new URL(url).getContent(); 
      Drawable d = Drawable.createFromStream(is, "src name"); 
      return d; 
     } 
     catch (Exception e) 
     { 
      System.out.println("Exc=" + e); 
      return null; 
     } 
    } 
+1

我可以從初學者看到下一個問題:「我得到一個NetworkOnUiThreadException」。你應該嘗試解釋一下,並在你的回答中顯示出一些努力。 「試試這個[一些代碼]」沒有什麼意義......(除了你在那裏的醜陋的東西外:'System.out.println()') – WarrenFaith 2013-03-22 12:04:59

0

而不是什麼其他人所提出的建議,我認爲要做到這一點的最好辦法是使用UniversalImageLoader。它將允許您延遲加載,並緩存在SD卡和內部存儲上。簡而言之,它使事情變得更簡單,並允許您以最快的速度進行。試試看。