Reputation: 489
So, in my project, I'm merging a few pieces of code, written earlier, into one application. I have :
Now, I would like to reuse those JavaFX forms on my Android application, but still be able to load my previous Android activities on some button click or sth.
Is there any way, this could be achieved ? Greetings
Upvotes: 1
Views: 610
Reputation: 16278
Android SDK doesn't come with any Java gui library. If it is mandatory for you to reuse the same form (i.e. refactoring will take weeks), Jose answer is probably what you need.
But if it's not mandatory (i.e. you just want to avoid 1 or 2 hours of writing code), I'd suggest you just re-code it using Android UI classes, as it will make it easier to maintain and scale in the future.
Upvotes: 0
Reputation: 45476
If you want to merge JavaFX and Android projects, you should have a look at the JavaFXPorts project.
You will be developing a JavaFX project that could be deployed both in desktop and on mobile platforms.
For that, you just need to include one single plugin on your build.gradle:
apply plugin: 'org.javafxports.jfxmobile'
For starters, you may consider using Gluon's plugin for NetBeans, that will create for you a JavaFX project where you can add your sources: you could add your existing JavaFX sources to the Main folder, and you could add also your Android activities to the Android folder.
You will have to adapt the Android activities so they run on the JavaFX thread with FXActivity.getInstance()
.
Have a look at this post with a sample of that.
You may also have a look at Gluon Charm Down library, that can be added to your project, to interact with native services, like GPS.
Keep in mind Android runs Dalvik VM, so you won't be able to use Java 8 new features (streams).
Upvotes: 2