0
我有一個自定義ListActivity
,它使用SimpleCursorAdapter
子類。在我的newView()
和bindView()
方法中,我試圖根據數據庫數據動態創建一個AnimationDrawable
。 ImageView僅顯示第一個drawable,並且不設置動畫。bindView中的AnimationDrawable用於自定義ListView適配器
@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);