ion java.lang.ClassCastException

plu*_*ism 0 android image classcastexception imageview android-ion

我使用ION(https://github.com/koush/ion)从网页中的图像加载到ListViewImageView.目前我想从中获取位图ImageView,但是我得到一个强制关闭我的应用程序的异常:

java.lang.ClassCastException: com.koushikdutta.ion.IonDrawable cannot be cast to android.graphics.drawable.BitmapDrawable
Run Code Online (Sandbox Code Playgroud)

这些是我正在使用的行:

final ImageView itemImageView = (ImageView)view.findViewById(R.id.photoImage);
final Bitmap itemDrawable = ((BitmapDrawable) itemImageView.getDrawable()).getBitmap();
Run Code Online (Sandbox Code Playgroud)

我怎么解决这个问题?提前致谢!

kou*_*ush 5

Ion设置自定义drawable来管理动画GIF,淡入淡出过渡等,因此无法将其强制转换为BitmapDrawable.

使用:

Ion.with(imageView).getBitmap()
Run Code Online (Sandbox Code Playgroud)

得到位图