This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]