In different Kotlin examples for Android I see toast("Some message...")
or toastLong("Some long message")
. For example:
While using Anko with Kotlin, inside fragment use either:
activity.toast("string message")
or
context.toast("string message")
or
view.holder.context.toast("string message")
Just to add on @nhaarman's answer --> you probably want to add the resourceId
support as well
fun Context.toast(resourceId: Int) = toast(getString(resourceId))
fun Context.toast(message: CharSequence) =
Toast.makeText(this, message, Toast.LENGTH_SHORT).show()
I have found very easy way to Toast from given link https://gist.github.com/felipearimateia/ee651e2694c21de2c812063980b89ca3. In this link Activity is used instead of Context. Try it.