public void init(Object context) { try { theme = UIManager.initNamedTheme("/theme", "material"); } catch (Exception e) { }
// Enable Toolbar on all Forms by default Toolbar.setGlobalToolbar(true); } public void start() { if(current != null){ current.show(); return; } Form hi = new Form("Toolbar", new BoxLayout(BoxLayout.Y_AXIS)); hi.getToolbar().addCommandToLeftBar("Native", null, (e) -> setTheme("Native")); hi.getToolbar().addCommandToRightBar("Material", null, (e) -> setTheme("material"));
hi.getToolbar().addCommandToSideMenu("Test", null, (e) -> setTheme("test"));
hi.show(); } public void setTheme(String theme) { Resources res = null; try { res = Resources.openLayered("/theme"); } catch (IOException e) { Log.p(e.toString()); } if (res != null) { UIManager.getInstance().setThemeProps(res.getTheme(theme)); Display.getInstance().getCurrent().refreshTheme(); }
}
and yes, I have the themes in my .res file