Hi Guys,
I would like to add a simple button to my AndroidHarness based activity.
what is the best practice to do so?
the AndroidHarness GLSurfaceView is stretched all over the activity and I want a button above it in the center-bottom of the screen.
I prefer it will be a simple regular android button but if there is a JME dedicated UI element I’ll settle for it as well.
Looking for best practice for adding UI elements to my app.
Thank you
Regarding GUI libraries… Last time i tried Lemur on android it had issues loading groovy-all - which i think paul actually wanted to look into but nobody was up for helping much. That leaves you with Nifty or TonegodGui. I cant really decide which one you should use, but those are the “out of the box” choices you have.
99% sure that groovy-all is only required if you want to use the styling language (or the default styles). If you choose to avoid loading the default glass style then it shouldn’t be an issue.
For a simple button, styles are probably not required. Either use the unstyled button or give it a simple quad background.
Button b = new Button(“Hello, world”);
b.setBackground(new QuadBackgroundComponent(ColorRGBA.Gray);
…or whatever.
guiNode.attachChild(b);
I was hoping someone would answer him regarding a native button but yeah, otherwise Lemur should work ok for a simple button with no styling.
If OP is curious:
Just avoid the “Initializing a Default Style” section on Android.
Yeah it’s a bit difficult to use Android stuff in jME. However, if you really want something like that, you can look at the file “src\main\res\layout\main.xml” or something. With button it should look like this:
Thank you guys. You gave me plenty of options to try out. I understand that it’s best practice not to use native Android GUI in JME apps so I’ll try that first.
If I remember correctly the JME-Android is implemented as a Fragment, right? Then in this case you can have your JME fragment next to Native components…
But I stopped developing on Android years ago, so I might be wrong…
Correct me if i’m wrong guys - it seems that Nifty is the “official” UI package for JME?
I’m trying to decide where to put my learning efforts.
So - which is the best UI package to use for the long term in your opinion?
I personally think Lemur is much much much much more jme aware as it has Spatials and the like you know from jme. Nifty is just a gui lib which also work with jme.
I worked with both and I like Lemur better (ok it lacks documentation a bit)
For some reason Lemur brings JME (ext.jmeVersion=‘3.1.0-alpha4’ // but must be alpha4 or better) Alpha version which collides with the current JME i’m using in my project.
Is there a way to tell it (in the gradle file) not to bring JME with it?
As long as @pspeed is around I’d pick Lemur, of course!
Otherwise, I’d just roll out my own (I don’t like Nifty and tonegodgui receive almost no support, unfortunately).
You want Lemur but don’t want JME???
What’s next, you want to run bytecode without a JVM?
Lemur requires some JME… the latest versions will work with any version after 3.1 alpha4… else you have to go back to a much earlier release if you are still using 3.0.
I’m using JME 3.1.0-stable. I have added it as a jar dependency so for some reason it collides with the JME3.1.0-alpha4 that gradle brings with Lemur.
Anyway, I managed to overcome the problem by removing the JME jar (from the dependency tab) and bring it via gradle. Now it works but I’m getting run-time exception regarding missing bulletjme??
All I wanted is to add a simple button to my Android activity
Can anyone assist with this bulletjme run-time problem - what should I do?
I’m confused… are you using gradle or the SDK? You have something very strange going on.
If your gradle project refers to JME 3.1 stable then it shouldn’t be bringing in alpha4 because stable is newer. That’s why all of the gradle-based Lemur examples work fine:
None of this has anything to do with bullet. Lemur definitely doesn’t use it.
Edit: just noticed that is referring to JME beta… but stable should work just the same.
I started using the SDK and it worked great. Then I tried to add Lemur via gradle and I started getting all kind of errors. Do you suggest working only with gradle?
What will my gradle dependencies will look like? I need JME+Lemur and it is an Android project
OK, removed all the gradle stuff and now adding the JARS in my project and getting this at run-time:
java.lang.NoClassDefFoundError: Failed resolution of: Ljavax/script/ScriptEngineManager;
at com.simsilica.lemur.style.StyleLoader.(StyleLoader.java:72)
at com.simsilica.lemur.style.StyleLoader.(StyleLoader.java:62)
at com.simsilica.lemur.style.BaseStyles.loadStyleResources(BaseStyles.java:72)
at com.simsilica.lemur.style.BaseStyles.loadGlassStyle(BaseStyles.java:62)
at com.scenemaxng.projector.SceneMaxApp.simpleInitApp(SceneMaxApp.java:55)
at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:220)
at com.jme3.app.AndroidHarness.initialize(AndroidHarness.java:478)
at com.jme3.system.android.OGLESContext.onDrawFrame(OGLESContext.java:328)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1590)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1286)
OK, so I remarked the two lines loading the “glass” style and now the app doesn’t crash and I can see the UI elements. It’s a major progress
Here is a link to my app in action. It’s going to be some kind of 3D scripting language for kids: https://www.youtube.com/watch?v=e9NX2U7vxV8
Guys where can I find Lenur sample codes?
For example I’m trying to find how to use Button.addClickCommands() and cant find any samples in the online docs…