我正在尝试在执行AsyncTask之前做一些动画,但似乎在完成ainmation(TranslateAnimation)之前执行了AsyncTask。无论如何我可以延迟AsyncTask直到完成ainmation?
TranslateAnimation aim = new TranslateAnimation(0, 0, 0, (y/4));
aim.setDuration(600);
aim.setFillAfter(true);
btn.startAnimation(aim);
new MyAsyncTask().execute(sTitle);
答案 0 :(得分:2)
似乎你需要尝试setAnimationListener。代码如下所示:
TranslateAnimation aim = new TranslateAnimation(0, 0, 0, (y/4));
aim.setDuration(600);
aim.setFillAfter(true);
aim.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(final Animation animation) {
// TODO: autogenerated code
}
@Override
public void onAnimationEnd(final Animation animation) {
new MyAsyncTask().execute(sTitle);
}
@Override
public void onAnimationRepeat(final Animation animation) {
// TODO: autogenerated code
}
});
btn.startAnimation(aim);