小编The*_*neX的帖子

Android:AnimationDrawable强制转换错误

我正在关注Google提供的如何将DynamicDrawable与ImageView一起使用的示例.您可以在此处找到它:http://developer.android.com/guide/topics/graphics/drawable-animation.html

imageView.setBackgroundResource(R.drawable.animation);
AnimationDrawable animation = (AnimationDrawable)imageView.getBackground();
animation.start();
Run Code Online (Sandbox Code Playgroud)

当我运行它时,我收到错误:

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

Google似乎认为这应该可行,但是如果你不能将BitmapDrawable强制转换为AnimationDrawable,我不确定它应该如何工作?

android animationdrawable

11
推荐指数
1
解决办法
1万
查看次数

标签 统计

android ×1

animationdrawable ×1