[Lazarus] Android Target GUI
michael.vancanneyt at wisa.be
michael.vancanneyt at wisa.be
Fri Feb 17 09:11:35 CET 2012
On Fri, 17 Feb 2012, Marc Santhoff wrote:
> Hi,
>
> I'd like to know, how GUI building for Android is handled using Lazarus.
>
> I have pretty much no idea of the Android SDK or things, but I
> understand that this target involves compiling the code to Java byte
> code. The details are not what I need at the moment, only a broad
> overview how things work together and what role Lazarus plays in the GUI
> part.
There are 2 approaches:
1. Do as Felipe does. He has described how it works.
2. Use the JVM backend. In that case, you make direct use of the Java
classes and the android API. Your app willl look and behave like any
other Android app. (I am not sure what Felipe's approach results in)
In the second case, Lazarus offers no help except that it's an excellent
Pascal editor/compiler. But the GUI designing part of Lazarus is then not
used. You must create the XML files manually.
>
> How is the GUI specified, is it drawn like building a form or is it made
> by drawing on a canvas in code?
Android uses XML files to specify the layout. This is the recommended way by
Google. You can build the GUI in code as well, but then you're pretty much in
uncharted territory.
>
> Or does Lazarus/fpc only generate the event handlers an making a GUI is
> a seperate task for a HTML designer or the like?
The android API does not know event handlers as Object Pascal does.
It has some form of callback objects, which are pretty much the same thing, yet
they work slightly different.
Basically, your class must expose a certain interface, and then it can be
assigned as the 'event handling object' to the GUI control.
It's probably easier to see it work in code than explain in words :-)
I just wrote an app in this way. It has about 160 lines of code (including
declaration) for a 2-form program that talks to a database to show some
stuff on screen.
Michael.
More information about the Lazarus
mailing list