我希望我的代码是可读的,所以我编写了不同的方法,无论它们做什么,都返回到onCreate,它调用下一个要执行的方法。我的一个方法有一个onAnimationEnd侦听器,我希望onCreate方法等待动画结束,然后调用next方法,如果不从侦听器本身调用next方法,我如何做到这一点?
提前感谢
onCreate()
{
doTask1();
doTask2();
}
private void doTask1(){
...
...
public void onAnimationEnd(Animation animation) {
// finish this method and let onCreate call the next one
}
}发布于 2013-03-13 21:40:52
要做到这一点,最好的方法是实现如下内容:
onCreate()
{
doTask1();
doTask2();
}
private void doTask1(){
Animation animation;
...
...
onAnimationEnd(animation);
}
public void onAnimationEnd(Animation animation) {
...
}如果onAnimationEnd方法是一个侦听器,我建议您实现如下内容:
onCreate() {
addActions(); //you can choose which method call first
doTask1();
doTask2();
}
private void addActions(){
...
...
public void onAnimationEnd(Animation animation) {
// finish this method and let onCreate call the next one
}
}
private void doTask1(){
...
}https://stackoverflow.com/questions/15093654
复制相似问题