我有一个使用ListActivity
子类的自定义SimpleCursorAdapter
。在我的newView()
和bindView()
方法中,我尝试动态创建AnimationDrawable
,具体取决于数据库数据。 ImageViews仅显示第一个drawable,而不显示动画。
@Override
public void bindView(View v, Context context, Cursor c) {
Resources res = context.getResources();
Drawable frame1 = null;
if(tt.getDrawable() != null) frame1 = res.getDrawable(tt.getDrawable());
ImageView icon = (ImageView) v.findViewById(R.id.idt_icon);
AnimationDrawable transition = new AnimationDrawable();
transition.addFrame(frame1, 500);
transition.addFrame(res.getDrawable(R.drawable.sunny_thought), 1000);
transition.start();
icon.setImageDrawable(transition);
答案 0 :(得分:1)
你可以试试这个
frameAnimation.setOneShot(false);
有时它应该是frameAnimation.stop();
,然后是frameAnimation.start();