こんにちは、アニメーション ドローアブルを一時停止しようとしましたが、成功しませんでした。スタック オーバーフローの助けを借りて、私は少なくとも animationDrawable エンド リスナーの助けを借りました。これがそのコードです。アニメーション Drawable を一時停止し、一時停止した場所から開始する方法はありますか...
public abstract class CustomAnimationDrawable extends AnimationDrawable{
/** Handles the animation callback. */
Handler mAnimationHandler;
Runnable r= new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
onAnimationFinish();
}
};
public CustomAnimationDrawable(AnimationDrawable aniDrawable) {
/* Add each frame to our animation drawable */
for (int i = 0; i < aniDrawable.getNumberOfFrames(); i++) {
this.addFrame(aniDrawable.getFrame(i), aniDrawable.getDuration(i));
}
}
@Override
public void start() {
super.start();
/*
* Call super.start() to call the base class start animation method.
* Then add a handler to call onAnimationFinish() when the total
* duration for the animation has passed
*/
mAnimationHandler = new Handler();
mAnimationHandler.postDelayed(r, getTotalDuration());
}
/**
* Gets the total duration of all frames.
*
* @return The total duration.
*/
public int getTotalDuration() {
int iDuration = 0;
for (int i = 0; i < this.getNumberOfFrames(); i++) {
iDuration += this.getDuration(i);
}
return iDuration;
}
/**
* Called when the animation finishes.
*/
abstract void onAnimationFinish();
public void destroy()
{
mAnimationHandler.removeCallbacksAndMessages(r);
mAnimationHandler.removeCallbacksAndMessages(null);
}
}
親切に助けてください一時停止する方法はありますか?