This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
verticalLayout { | |
val name = editText() | |
button("Say Hello") { | |
onClick { toast("Hello, ${name.text}!") } | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val act = this | |
val layout = LinearLayout(act) | |
layout.orientation = LinearLayout.VERTICAL | |
val name = EditText(act) | |
val button = Button(act) | |
button.text = "Say Hello" | |
button.setOnClickListener { | |
Toast.makeText(act, "Hello, ${name.text}!", Toast.LENGTH_SHORT).show() | |
} | |
layout.addView(name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun result() = | |
html { | |
head { | |
title {+"XML encoding with Kotlin"} | |
} | |
body { | |
h1 {+"XML encoding with Kotlin"} | |
// an element with attributes and text content | |
a(href = "http://kotlinlang.org") {+"Kotlin"} | |
// mixed content |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const val kotlinVersion = "1.3.21" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Pluggins{ | |
const val androidApplication = "com.android.application" | |
const val kotlinAndroid = "kotlin-android" | |
const val kotlinAndroidExtensions = "kotlin-android-extensions" | |
const val googleServices = "com.google.gms.google-services" | |
} | |
object AndroidSdk { | |
const val min = 21 | |
const val compile = 29 | |
const val target = compile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Build { | |
object Versions { | |
const val buildToolsVersion = "3.4.2" | |
const val googleServicesVersion = "4.2.0" | |
} | |
const val androidGradlePlugin = "com.android.tools.build:gradle:${Versions.buildToolsVersion}" | |
const val kotlinGradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" | |
const val googleServicesPlugin = | |
"com.google.gms:google-services:${Versions.googleServicesVersion}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Usamos las variables del objeto Pluggins | |
apply plugin: (Pluggins.androidApplication) | |
apply plugin: (Pluggins.kotlinAndroid) | |
apply plugin: (Pluggins.kotlinAndroidExtensions) | |
apply plugin: (Pluggins.googleServices) | |
//Usamos las variables del objeto AndroidSdk | |
android { | |
compileSdkVersion (AndroidSdk.compile) | |
buildToolsVersion (AndroidSdk.buildToolsVersion) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buildscript { | |
repositories { | |
google() | |
jcenter() | |
} | |
//Usamos las variables del objeto Build | |
dependencies { | |
classpath (Build.androidGradlePlugin) | |
classpath (Build.kotlinGradlePlugin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const val kotlinVersion = "1.3.21" | |
object Build { | |
object Versions { | |
const val buildToolsVersion = "3.4.2" | |
const val googleServicesVersion = "4.2.0" | |
} | |
const val androidGradlePlugin = "com.android.tools.build:gradle:${Versions.buildToolsVersion}" | |
const val kotlinGradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
repositories { | |
jcenter() | |
} | |
plugins { | |
`kotlin-dsl` | |
} | |
kotlinDslPluginOptions { | |
experimentalWarning.set(false) |
NewerOlder