Converting Java Code to work with Android
Hello,
I am a beginner with Java in that I have worked through examples from a book. I would like to start programming android applications (simple ones). I know Android Apps use java (I can see the similarities) but words are different to some extent. Would it be effective to convert standard java code (don't know what to call this) to java code used in Android Apps (dont know what to call this)? Or should I start fresh, remember I am just starting out here? In general what changes are there. The first difference I noticed was the package declarations. I just want to know what I am getting into. Thanks in advance.
Re: Converting Java Code to work with Android
It is possible to convert some java code directly, but more often than not porting a java program to android will take significant effort, particularly when it comes to i/o and the gui interface. Packages are a part of standard java and android. The biggest differences I can see are the API's available and the execution model. Personally I would recommend getting familiar with java and general programming first before delving too deep into android.
Re: Converting Java Code to work with Android
Well if you don't mix gui stuff with non-gui stuff, then you will have to change only a small part of your application.
Java applications use Swing and Android has its own components that do similar things.
There is not a one to one translation for the components but some are straight forward enough .
In general Swing is more advanced than Android SDK , so if you master it you should be able to convert your app relatively easily.
I find the layouts in android to be somewhat short, and some important components such as JTable are lacking (maybe a tablelayout will do).
I am a _beginner_ in Android myself so here are some difficulties I encountered :
- layouts in general
- jtable
- tabs (jtabbedpane is easier to handle)
- combo-box (maybe Editbox + Spinner)
- Jpanel (maybe be a FrameLayout will do).