安卓框架动画无法在BaseAdapter中工作



我正在从服务器下载图像,并以位图格式存储在数组中,然后我初始化帧动画,并想从我之前制作的数组中对其进行动画处理,

我面临的问题是帧动画没有动画。。

final AnimationDrawable frame_anim=new AnimationDrawable();
frame_anim.addFrame(new BitmapDrawable(context.getResources(),stadium_list.get(position)), 100);
frame_anim.addFrame(new BitmapDrawable(context.getResources(),sponser_list.get(position)), 100);
stadium_image.setBackgroundDrawable(frame_anim);
frame_anim.setVisible(true, true);
frame_anim.setOneShot(false);
notifyDataSetChanged();
stadium_image.postDelayed(new Runnable() {
    @Override
    public void run() {
        // TODO Auto-generated method stub
        frame_anim.start();
        Toast.makeText(context, "Animation", 1000).show();
    }
}, 3000);

您的代码显示您错过了获取已编译为AnimationDrawable对象的背景。

AnimationDrawable frameAnimation=(AnimationDrawable)YOURIMAGEVIEW.getBackground();

动画可绘制

最新更新