我为一款应用程序制作了一个简单的侧边菜单。第一次调用菜单时,它显示正常。
当我第二次调用菜单时,我看到一个空白屏幕。
这是我构建菜单的方式:
package com.mainsys.zappeion;
import static com.codename1.ui.CN.*;
import com.codename1.ui.Form;
import com.codename1.ui.Dialog;
import com.codename1.ui.plaf.UIManager;
import com.codename1.ui.util.Resources;
import com.codename1.io.Log;
import com.codename1.ui.Toolbar;
import com.codename1.ui.FontImage;
/**
* This file was generated by <a href="https://www.codenameone.com/">Codename One</a> for the purpose
* of building native mobile applications using Java.
*/
public class Zappeion {
private Form current;
private Resources theme;
public void init(Object context) {
// use two network threads instead of one
updateNetworkThreadCount(2);
theme = UIManager.initFirstTheme("/theme");
// Enable Toolbar on all Forms by default
Toolbar.setGlobalToolbar(true);
// Pro only feature
Log.bindCrashProtection(true);
addNetworkErrorListener(err -> {
// prevent the event from propagating
err.consume();
if(err.getError() != null) {
Log.e(err.getError());
}
Log.sendLogAsync();
Dialog.show("Connection Error", "There was a networking error in the connection to " + err.getConnectionRequest().getUrl(), "OK", null);
});
}
public void start() {
if(current != null){
current.show();
return;
}
Toolbar tb = new Toolbar();
Statues statues = new Statues();
statues.setToolbar(tb);
tb.addMaterialCommandToSideMenu("Αγάλματα", FontImage.MATERIAL_ALBUM, e -> {
statues.show();
});
Sights sights = new Sights();
sights.setToolbar(tb);
tb.addMaterialCommandToSideMenu("Αξιοθέατα", FontImage.MATERIAL_ALBUM, e -> {
sights.show();
});
Map map = new Map();
map.setToolbar(tb);
tb.addMaterialCommandToSideMenu("Χάρτης ", FontImage.MATERIAL_ALBUM, e -> {
map.show();
});
MainSys mns = new MainSys();
mns.setToolbar(tb);
SplashScreen sc = new SplashScreen(); //(sights, mns);
sc.setToolbar(tb);
sc.show();
}
public void stop() {
current = getCurrentForm();
if(current instanceof Dialog) {
((Dialog)current).dispose();
current = getCurrentForm();
}
}
public void destroy() {
}
}
在上面的代码中,例如如果我点击菜单中的“景点表格”,它会正常显示。但是,如果我再次点击此菜单,则会得到一个空白屏幕,没有菜单工具栏和任何内容。
感谢您的帮助。