|
发表于 2012-6-26 21:16:59
|
显示全部楼层
我没有做过安卓,做非智机出身的,看了代码,知道你的问题出在哪了.
你这样做:
new一个接口Icb,AnimationDrawable manimation后,立马 manimation.setCallback(Icb);
怎么方便怎么做,你自己看下AnimationDrawable.java和 Drawable.java就明白drawwable实现动画的原理了,
接口如下,注意第一方法也要实现,我估计你不实现的话,可能没法更新了,一直停在第一帧
public static interface Callback {
/**
* Called when the drawable needs to be redrawn. A view at this point
* should invalidate itself (or at least the part of itself where the
* drawable appears).
*
* @param who The drawable that is requesting the update.
*/
public void invalidateDrawable(Drawable who);
/**
* A Drawable can call this to schedule the next frame of its
* animation. An implementation can generally simply call
* {@link android.os.Handler#postAtTime(Runnable, Object, long)} with
* the parameters <var>(what, who, when)</var> to perform the
* scheduling.
*
* @param who The drawable being scheduled.
* @param what The action to execute.
* @param when The time (in milliseconds) to run. The timebase is
* {@link android.os.SystemClock#uptimeMillis}
*/
public void scheduleDrawable(Drawable who, Runnable what, long when);
/**
* A Drawable can call this to unschedule an action previously
* scheduled with {@link #scheduleDrawable}. An implementation can
* generally simply call
* {@link android.os.Handler#removeCallbacks(Runnable, Object)} with
* the parameters <var>(what, who)</var> to unschedule the drawable.
*
* @param who The drawable being unscheduled.
* @param what The action being unscheduled.
*/
public void unscheduleDrawable(Drawable who, Runnable what);
} |
|