Codename One - Transition from FormA to FormB to FormC

馋奶兔 提交于 2019-12-08 07:54:39

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!