程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> imageview-異步任務加載圖片報錯

imageview-異步任務加載圖片報錯

編輯:編程綜合問答
異步任務加載圖片報錯

執行圖片異步任務,學習連接:

http://schimpf.es/asynctask-for-image-download/

在代碼中:

ImageView im1 = (ImageView) findViewById(R.id.image);
ImageDownloadTask imageD = new ImageDownloadTask(im1);
imageD.execute(e.mediumLabel);

結果報出的錯誤:

06-19 15:22:23.480: E/AndroidRuntime(18376): FATAL EXCEPTION: AsyncTask #2
06-19 15:22:23.480: E/AndroidRuntime(18376): java.lang.RuntimeException: An error occured while executing doInBackground()
06-19 15:22:23.480: E/AndroidRuntime(18376):    at android.os.AsyncTask$3.done(AsyncTask.java:299)
06-19 15:22:23.480: E/AndroidRuntime(18376):    at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
06-19 15:22:23.480: E/AndroidRuntime(18376):    at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
06-19 15:22:23.480: E/AndroidRuntime(18376):    at java.util.concurrent.FutureTask.run(FutureTask.java:239)
06-19 15:22:23.480: E/AndroidRuntime(18376):    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
06-19 15:22:23.480: E/AndroidRuntime(18376):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
06-19 15:22:23.480: E/AndroidRuntime(18376):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
06-19 15:22:23.480: E/AndroidRuntime(18376):    at java.lang.Thread.run(Thread.java:856)
06-19 15:22:23.480: E/AndroidRuntime(18376): Caused by: java.lang.NullPointerException: println needs a message
06-19 15:22:23.480: E/AndroidRuntime(18376):    at android.util.Log.println_native(Native Method)
06-19 15:22:23.480: E/AndroidRuntime(18376):    at android.util.Log.e(Log.java:231)
06-19 15:22:23.480: E/AndroidRuntime(18376):    at com.example.beerportfoliopro.ImageDownloadTask.doInBackground(ImageDownloadTask.java:42)
06-19 15:22:23.480: E/AndroidRuntime(18376):    at com.example.beerportfoliopro.ImageDownloadTask.doInBackground(ImageDownloadTask.java:1)
06-19 15:22:23.480: E/AndroidRuntime(18376):    at android.os.AsyncTask$2.call(AsyncTask.java:287)
06-19 15:22:23.480: E/AndroidRuntime(18376):    at java.util.concurrent.FutureTask.run(FutureTask.java:234)

最佳回答:


給你個建議,當報錯時最好看這些:Caused by: java.lang.NullPointerException: println

NullPointerException這個意思是空指針報錯。沒有傳對對象。。。

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved