How do you display a Toast using Kotlin on Android?

前端 未结 15 2211
遇见更好的自我
遇见更好的自我 2021-01-30 16:08

In different Kotlin examples for Android I see toast("Some message...") or toastLong("Some long message"). For example:



        
15条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-30 16:29

    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")
    

提交回复
热议问题