Kotlin is a reality for Android. Here, I show some examples of how Kotlin can help you improve your productivity on Android and make your life much easier.
= Toast.LENGTH_SHORT){ Toast.makeText(this, message, length).show() } override fun onCreate(savedInstanceState: Bundle?) { … toast("This is a toast") toast("This is a long toast", Toast.LENGTH_LONG) } extensions.kt MainActivity.kt
is a toast"); ExtensionsKt.toast(this, "This is a long toast", Toast.LENGTH_LONG); @JvmOverloads fun Context.toast(…){ Toast.makeText(this, message, length).show() } MyJavaActivity.java extensions.kt
is a toast"); ExtensionsKt.toast(this, "This is a long toast", Toast.LENGTH_LONG); @JvmOverloads fun Context.toast(…){ Toast.makeText(this, message, length).show() } MyJavaActivity.java extensions.kt