本文介绍了代号一-从FormA到FormB到FormC的过渡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下代码可在Codename One模拟器上按预期工作,即:
The following code works as expected on the Codename One simulator, that is:
- 显示第一个表单(startForm)
- 淡入第二个表单(emptyForm)两秒钟
- 淡入第三个表单1秒(loginForm)
因此过渡时间总计应为三秒。
So the transition duration should be three seconds in total.
但是在实际设备上,第三个表格几乎立即显示。我的代码有什么问题?
But on real devices the third Form is shown almost immediately. What's wrong in my code?
// Transition from startForm to loginForm
startForm.show();
startForm.setTransitionOutAnimator(CommonTransitions.createFade(2000));
emptyForm.show();
emptyForm.setTransitionOutAnimator(CommonTransitions.createFade(1000));
UITimer.timer(2000, false, emptyForm, new Runnable() {
@Override
public void run() {
loginForm.show();
}
});
推荐答案
show()
是非阻塞的,因此按这样的顺序调用它不是一个好主意。
show()
is non-blocking so calling it in sequence like this isn't a good idea. It could cut the transition time effect or even collide.
完成此操作的方法是:
startForm.addShowListener(e -> {
emptyForm.addShowListener(ee -> loginForm.show());
emptyForm.show();
});
这篇关于代号一-从FormA到FormB到FormC的过渡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!