Even if you are new to Scaloid, you may easily get the point of the code. As you expected, if you clicked the button, the toast message "Bang!" is shown.

In styles of Android SDK or even in CSS, only static properties can be assigned (such as color, margin, font, etc ...). However, Scaloid can do anything with the component, such as assigning onClick behavior, adding a new component, or replacing the component itself with another component.

For example, Scaloid styles can append another view component to the layout. let's start with a very simple code:

new SVerticalLayout {
SEditText("Name")
SEditText("Address")
}

Needless to say, this shows an input field with the default value "Name", as shown below:

The value "Name" is moved to a new text view. Also, if you moved the focus, the toast "You entered: ..." will be shown.

The signiture of the style function is style(stl: View => View). That means the style specification should return a view component, that is actually visualized on the screen. Therefore you can return another component to replace the original. For example:

Type-safety for your pleasure

Thanks to Scala language, all of these examples are type-safe, which means that auto-completion of your IDE will suggest valid candidates, and if you made a mistake, IDE will warn you and the code will not be compiled at all.