'receiver type mismatch' with Fragment and Anko toast

后端 未结 2 624
陌清茗
陌清茗 2021-01-23 01:53

I am trying to use Jetbrains\' Anko library to easily display an Android toast message in my app.

Here is the relevant code snippet:

val message : CharSe         


        
2条回答
  •  爱一瞬间的悲伤
    2021-01-23 02:11

    I encountered the same issue using import android.support.v4.app.Fragment.

    As Kingsley Adio said in a previous comment, add the following line in the dependencies specified in your module gradle file:

    dependencies 
    {
    ...
        implementation "org.jetbrains.anko:anko-support.v4-commons:$your_anko_version"
    ...
    }
    

    Then add this import in your .kt file:

    import org.jetbrains.anko.support.v4.toast
    

提交回复
热议问题