This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
simplified Android View construction with Kawa
- From: Per Bothner <per at bothner dot com>
- To: "kawa at sourceware dot org" <kawa at sourceware dot org>
- Date: Mon, 19 Nov 2012 11:40:07 -0800
- Subject: simplified Android View construction with Kawa
I checked in some changes to Kawa so you can leave our the initial Activity
parameter when constructing a View instance. This makes the Scheme code
close to the conciseness of the XML layout form:
(require 'android-defs)
(activity hello
(on-create-view
(define counter ::integer 0)
(define counter-view
(TextView (this) text: "Not clicked yet."))
(LinearLayout orientation: LinearLayout:VERTICAL
(TextView text: "Hello, Android from Kawa Scheme!")
(Button
text: "Click here!"
on-click-listener: (lambda (e)
(set! counter (+ counter 1))
(counter-view:setText
(format "Clicked ~d times." counter))))
counter-view)))
This creates a vertical LinearLayout consisting of a Text, a Button,
and a Text. The later text (counter-view) is updated each time the
Button is clicked.
This is a work-in-progress, and I have other improvements in mind,
but I think this is a nice little simplification.
--
--Per Bothner
per@bothner.com http://per.bothner.com/