Automatic implicit conversions and extensions functions for the Android framework in Scala


Join the chat at

Generated implicit conversions and extension functions for the Android framework in Scala


All interfaces and abstract classes with a single abstract method have been wrapped by an implicit conversion for the corresponding function.

On top of that, all methods that take these objects as a single parameter have been enhanced to take an automatically typed function or by-name parameter.

The extension functions are named with any prefixed set and suffixed Listener names removed. Additionally, the remainder of the name is decapitalized. For example setOnClickListener becomes onClick and setInterpolator becomes interpolator.

When there are are callbacks with arguments that can be ignored, one can invoke the 0 variant of the extension function, such as onClick0 to pass a => A by-name parameter

1.3+: If there is a naming collision in an existing method name, such as with TextView.onEditorAction, the asScala extension function will wrap the object with the extension wrapper, and it can be called without encountering the naming conflict. e.g. textview.asScala.onEditorAction((a,b,c) => true); this has no allocation cost.

Use it from SBT

Base android framework extensions:

libraryDependencies += "" %% "scala-conversions" % "23.1.1"

Extensions for support-v4:

libraryDependencies += "" %% "scala-conversions-v4" % "23.1.1"

Extensions for appcompat-v7:

libraryDependencies += "" %% "scala-conversions-appcompat" % "23.1.1"

Extensions for design:

libraryDependencies += "" %% "scala-conversions-design" % "23.1.1"

Versions will generally track supportSdkVersion numbers, suffixed with letters to represent local fixes. Other versions can be generated upon request.

Use it from code


findViewById( { v => Toast.makeText(...).show() }


findViewById( { Toast.makeText(...).show() }







From 1.2 onward, generated sources are published to sonatype and browsable from IntelliJ.

generated code