我这里有一个问题。这冻结了我的Android手机,虽然它在模拟器上运行得很好,但它是在点击工具栏命令时执行的。
getContentPane().replace(getContentPanel().getComponentAt(0),createAbout(),CommonTransitions.createCover(CommonTransitions.SLIDE_HOLUTIONS,false,100));
我认为这是因为过渡。有什么帮助吗?
如果你只想动画替换,你可以做的是:
getContentPane().replace(getContentPane().getComponentAt(0), createAbout(), null);
getContentPane().animateLayoutAndWait(200);
在当前实现中,如果同时运行两个动画(替换、布局等),则可能会创建一个无效状态,从而触发异常/冻结。
如果有可能的话,你需要在开始动画之前设置一个标志,并在完成后发布,例如:
if(!globalLockFlag) {
globalLockFlag = true;
// change stuff and use animateLayoutAndWait or replaceAndWait
globalLockFlag = false;
} else {
// use timer or callSerially to postpone or skip animation entirely
}