我正在使用画布开发一个 j2me 应用程序。在我的应用程序中,我有 3 个画布。我需要定期切换它们,但有时我会遇到问题,要么它们不切换,要么我得到空白屏幕
我用
display.setCurrent(maincanvas);
但它仍然无法正常工作
Display.getDisplay(midlet).setCurrent(((MidletName)midlet).MethodName());
每当你想切换你的画布代码时,你都可以在画布中输入这一行。创建对象画布后,在 midlet 中创建方法。例如:
Splash hitSplash;
private Canvas gameView=null;
startApp() {
hitSplash= new CanvasClass(this);
Display.getDisplay(this).setCurrent(hitSplash);
}
public Canvas getMenu1()
{
if (gameView!=null) gameView = null;
gameView = new CrackerWindow(this,getSplash());
System.gc();
return gameView;
}
private Splash getSplash()
{
return hitSplash;
}