MaterialScreensUIKit doesn't show hamburger (sidemenu)

17 views
Skip to first unread message

howud...@gmail.com

unread,
Oct 12, 2017, 9:26:35 PM10/12/17
to CodenameOne Discussions
using MaterialScreensUIKit and the following code:
     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();
}

    }



shows no side menu.  



and yes, I have the themes in my .res file


However starting with "Native" (I renamed Theme1 from when the project was created) and then switch to the material theme it shows the hamburger icon, but then of course there are a ton of other artifacts.

Peter

Shai Almog

unread,
Oct 13, 2017, 1:31:33 AM10/13/17
to CodenameOne Discussions
Changing themes dynamically can cause issues with some theme constant behaviors.

howud...@gmail.com

unread,
Oct 13, 2017, 10:43:35 AM10/13/17
to CodenameOne Discussions
I am quite aware of that.  I must not have asked my question clearly enough.  When I start with material the hamburger icon is not visible.  When I switch from native to material the icon is visible, but there are other artifacts (as I mentioned in my first post).

Shai Almog

unread,
Oct 14, 2017, 2:29:29 AM10/14/17
to CodenameOne Discussions
I think that in that specific demo I chose to hide the side menu icon so I can add it manually in the code.

howud...@gmail.com

unread,
Oct 15, 2017, 5:27:45 PM10/15/17
to CodenameOne Discussions
I am only using the theme from that demo, not all the code.  The code I am using was in the first post.  I dont know if that makes a difference or not.  In any case it seems only natural to me to provide the response to the next question:  how do I turn it on?  and as a followup question, how do I chose to not hide the side menu icon so it's on by default?

Shai Almog

unread,
Oct 16, 2017, 2:08:38 AM10/16/17
to CodenameOne Discussions
There is a theme constant to hide the side menu. Just remove it from the theme
Reply all
Reply to author
Forward
0 new messages