Friday 13 January 2012

Android events in Oxygene for Java

When I first started looking at the Android SDK I quickly realised that events were set up differently to the frameworks I had worked with before. Instead of being defined as closures, or method pointers, event fields are defined using interface types. To handle an event you need to implement the interface in some class.

In Java this is done using some syntactic sugar that gets the compiler to implement the interface in an anonymous helper class. When working with the Oxygene language we also need this syntactic sugar to avoid degenerating into a mess of unwieldy code, hence the introduction of inline interface implementation.

There are various ways of using inline interface implementation and a couple of other options for implementing events, so I’ve written up a short article illustrating the primary options available for those using Oxygene for Java called Android event handling & inline interface implementation with Oxygene for Java. If interested in following up on this, you can find the article here on my web site.

No comments:

Post a Comment