2011-12-08 39 views
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); 

回答

1

你有時可以試試這個

frameAnimation.setOneShot(false); 

應該frameAnimation.stop();然後frameAnimation.start();

相關問題