问题
The following code works as expected on the Codename One simulator, that is:
- show first Form (startForm)
- fade to the second Form (emptyForm) for two seconds
- fade to the third Form for one second (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();
}
});
回答1:
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.
The way to accomplish this is:
startForm.addShowListener(e -> {
emptyForm.addShowListener(ee -> loginForm.show());
emptyForm.show();
});
来源:https://stackoverflow.com/questions/47521900/codename-one-transition-from-forma-to-formb-to-formc