2011-12-24 6 views
0

나는애니메이션 드로어 블 AnimationDrawable

runtime-
ImageView couponImage = (ImageView) findViewById(R.id.couponImg); 
    couponImage.setBackgroundResource(R.drawable.coupon); 

    AnimationDrawable couponAnimation = (AnimationDrawable)  
couponImage.getBackground(); 
    couponAnimation.start(); 

으로부터이 코드에 오류가 발생합니다. 하지만 "AnimationDrawable couponAnimation"을 사용하지 않으면 일식이 불평합니다.

답변

1
ImageView couponImage = (ImageView) findViewById(R.id.couponImg); 

AnimationDrawable couponImg = 
      (AnimationDrawable) getResources().getDrawable(R.drawable.couponImg); 

couponImg.setBackgroundDrawable(couponImg); 

couponImg.start(); 
관련 문제