Java 暂停应用程序,直到AnimationDrawable完成
我是Android开发新手。我在编写一个暂停应用程序直到动画结束的方法时遇到问题 这是我的代码:Java 暂停应用程序,直到AnimationDrawable完成,java,android,Java,Android,我是Android开发新手。我在编写一个暂停应用程序直到动画结束的方法时遇到问题 这是我的代码: public void CorrectAnimation() { Log.d("CorrectAnim", "Pass" ); final Button answer_1 = (Button) findViewById(R.id.answer_1); final Button answer_2 = (Button) findViewById(R.id.
public void CorrectAnimation() {
Log.d("CorrectAnim", "Pass" );
final Button answer_1 = (Button) findViewById(R.id.answer_1);
final Button answer_2 = (Button) findViewById(R.id.answer_2);
final Button answer_3 = (Button) findViewById(R.id.answer_3);
final Button answer_4 = (Button) findViewById(R.id.answer_4);
if (iAnswer_1 == 1) {
answer_1.setBackgroundResource(R.drawable.button_correctly);
AnimationDrawable animAnswer_1 = (AnimationDrawable) answer_1.getBackground();
animAnswer_1.start();
checkIfAnimationDone(animAnswer_1);
}
...
}
private void checkIfAnimationDone(AnimationDrawable anim){
Log.d("Check", "Pass" );
final AnimationDrawable a = anim;
int timeBetweenChecks = 2500;
Handler h = new Handler();
h.postDelayed(new Runnable(){
@override
public void run(){
Log.d("checkRun", "Pass" );
if (a.getCurrent() != a.getFrame(a.getNumberOfFrames() - 1)){
Log.d("checkRunIf", "Pass" );
checkIfAnimationDone(a);
} else{
Toast.makeText(getApplicationContext(), "ANIMATION DONE!", Toast.LENGTH_SHORT).show();
}
}
}, timeBetweenChecks);
};
问题是checkIfAnimationDone忽略了方法运行
解决方法:我忘记在公共运行之上添加@override。代码正在运行:检查这个问题,他正在使用onAnimationFinished方法进行过度编译