android中如何是使动画执行完后,再执行后面的代码?求指点
下面是我写的冒泡排序实现代码,但是一点击按钮,所有泡上冒,并完成排序
我想要实现的是先让两个泡上冒,然后比较,然后交换,再下来,再让两个泡上冒,依次,求指点
for(int i=0;i<bubbles.length-1;i++) {
for(int j=0;j<bubbles.length-1-i;j++) {
Animation a1=AnimationUtils.loadAnimation(this, R.anim.translate_down);
circles[j].startAnimation(a1);
circles[j+1].startAnimation(a1);
a1.setAnimationListener(this);
if(bubbles[j].getNumber()<bubbles[j+1].getNumber()) {
int temp = bubbles[j].getNumber();
bubbles[j].setNumber(bubbles[j+1].getNumber());
circles[j].setText(""+bubbles[j].getNumber());
bubbles[j+1].setNumber(temp);
circles[j+1].setText(""+bubbles[j+1].getNumber());
}
}
}