[Lazarus] Android Target GUI
Marc Santhoff
M.Santhoff at web.de
Sun Feb 26 14:26:10 CET 2012
Am Freitag, den 17.02.2012, 10:23 +0100 schrieb Felipe Monteiro de
Carvalho:
> On Fri, Feb 17, 2012 at 9:11 AM, <michael.vancanneyt at wisa.be> wrote:
> > 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.
>
> It is pretty trivial to build the UI without XML. I never used the XML
> part while programming for Android. For example (in pseudo-code):
>
> procedure TMyActivity.OnCreate;
> var
> layout: TAbsoluteLayout;
> params: TAbsoluteLayout_LayoutParams;
> tv: TTextView;
> et: TTextView;
> btn: TButton;
> ClickCount: Integer = 0;
> begin
> // Prepares the UI of the program
> layout := TAbsoluteLayout.Create;
>
> tv := TTextView.Create;
[...]
> params.Free;
>
> btn := TButton.Create;
> btn.setText('Go!');
> btn.setOnClickListener(@buttonClickCallback);
> params := TAbsoluteLayout_LayoutParams.Create(320, 50, 0, 60);
> layout.addView(btn, params);
> params.Free;
>
> Activity.setContentView(layout);
> end;
Very similar to what Java IDEs generate for form building code. ;)
Beautiful, very easy to handle and reagularly looking code. Besides
having to self draw any component that's nice. But by code reuse the
drawing issue will be solved very soon once started, I assume.
Thank you!
Marc
--
Marc Santhoff <M.Santhoff at web.de>
More information about the Lazarus
mailing list