Android - ViewRootImpl$CalledFromWrongThreadException

前端 未结 4 1263
有刺的猬
有刺的猬 2020-11-30 12:28

I was using this, to DISPLAY IMAGES FROM THE INTERNET but it throws an error as below:
04-12 13:45:05.337: E/AndroidRuntime(27897): Caused by: android.view.View

4条回答
  •  一向
    一向 (楼主)
    2020-11-30 12:48

    I think this line is causing the error..

      imageView.setImageDrawable(createDrawableFromURL("http://savagelook.com/misc/sl_drop2.png"));
    

    and the error explains why it is so..

         Only the original thread that created a view hierarchy can touch its views.
    

    this error is caused because you are trying to change the User Interface on mainthread from some other thread.. here doInBackground in your case...

提交回复
热议问题