0

I am new to mobile development, I started using Gluon mobile for Netbeans and I'm trying to add a Bottom navigation bar to the default Gluon Mobile App. They describe the class in the JavaDoc http://docs.gluonhq.com/charm/javadoc/4.1.0/com/gluonhq/charm/glisten/control/BottomNavigation.html but I can't seem to make it work. Would someone be able to post a snippet on how and where to do this?

SergioM
  • 45
  • 5

1 Answers1

0

Here is a simple example:

public class GluonApplication extends MobileApplication {

@Override
public void init() {

    addViewFactory(HOME_VIEW, () ->
    {

        StackPane root = new StackPane();
        root.getChildren().add(new Label("test"));

        View view = new View(root) {

            @Override
            protected void updateAppBar(AppBar appBar) {
                appBar.setTitleText("Home");
            }

        };
        view.setBottom(createBottomNavigation());
        return view;
    });

}

private BottomNavigation createBottomNavigation() {
    BottomNavigation bottomNavigation = new BottomNavigation();

    ToggleButton btn1 = bottomNavigation.createButton("View1", MaterialDesignIcon.DASHBOARD.graphic(), e -> showView("view1"));
    ToggleButton btn2 = bottomNavigation.createButton("View2", MaterialDesignIcon.AC_UNIT.graphic(), e -> showView("view2"));
    ToggleButton btn3 = bottomNavigation.createButton("View3", MaterialDesignIcon.MAP.graphic(), e -> showView("view3"));

    bottomNavigation.getActionItems().addAll(btn1, btn2, btn3);

    return bottomNavigation;
}

private void showView(String viewName) {
    MobileApplication.getInstance().switchView(viewName);
}

}

jns
  • 6,017
  • 2
  • 23
  • 28
  • Netbeans is not finding the class BottomNavigation, am I missing a library? I'm using `import com.gluonhq.charm.glisten.control.BottomNavigation; – SergioM Nov 24 '16 at 07:15
  • Thanks for your response, I do have the plugin installed, but I keep getting the error "Cannot find symbol" in the import statement. – SergioM Nov 24 '16 at 20:12
  • Have you tried to reload your project? http://stackoverflow.com/questions/40560461/cant-use-android-javafxports-api-in-gluon-project – jns Nov 25 '16 at 02:16
  • Yes, reloaded, restarted NetBeans, restarder computer, uninstalled and reinstalled gluon plugin. Nothing seems to work – SergioM Nov 26 '16 at 01:42
  • Can you post your build.gradle? – jns Nov 26 '16 at 02:24
  • You have to update to `compile 'com.gluonhq:charm:4.1.0'` since `BottomNavigation` was introduced in Charm 3.1.0 (and optionally to`org.javafxports:jfxmobile-plugin:1.1.1`) – jns Nov 26 '16 at 18:34