ClassCastException when casting an ImageView context to an Activity
I don't understand why I'm receiving a ClassCastException when I use this line:
Activity a=(Activity)photoToLoad.imageView.getConte开发者_如何学Goxt();
That is taken from the LazyList example (the second answer) and in that project it works, but when I use the class in mine, it doesn't work. It is necessary to obtain an Activity to use the runOnUIThread method to set the downloaded Bitmap to the ImageView and avoid handlers. What am I doing wrong?
Because all activities are contexts, but not all contexts are activities. I think the ImageView was not created from an activity.
精彩评论