What is in scala -android.jar?

I tried to experiment with developing Android applications using Scala.

I got to the point that I can get an application to compile, but there are no helper functions for things like:

button.setOnClickListener( () => {
    text.setText("test")
})

(I'm talking about closing there)

I see a lot of links to scala -android.jar and have this file in my project, but I'm not sure what it does or how to use it. I feel like I have support functions, but I'm not sure. Executing jar -tvf scala-android.jarin a file gives me the following:

401 Sun Jun 06 10:06:02 MDT 2010 scala/Function0$class.class
431 Sun Jun 06 10:06:02 MDT 2010 scala/Function0.class
572 Sun Jun 06 10:06:02 MDT 2010 scala/Function1.class
282 Sun Jun 06 10:06:02 MDT 2010 scala/ScalaObject$class.class
271 Sun Jun 06 10:06:02 MDT 2010 scala/ScalaObject.class
458 Sun Jun 06 10:06:02 MDT 2010 scala/runtime/BoxedUnit.class

If this is not what I'm looking for, is there a simple library that will do the conversion for this kind of thing?

+3
source share
1 answer

, , Scala.

, .

trait FindView
{
    this: Activity =>

    def findView [WidgetType] (id: Int) : WidgetType = {
        return findViewById (id).asInstanceOf[WidgetType]
    }

    implicit def listenerFromFunction (action: () => Any) = {
        new View.OnClickListener() {
            def onClick(v: View) {action ()}
        }
    }
}

Activity, , .

+8

Source: https://habr.com/ru/post/1748742/


All Articles