'receiver type mismatch' with Fragment and Anko toast

后端 未结 2 622
陌清茗
陌清茗 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
    
    0 讨论(0)
  • 2021-01-23 02:17

    Since the error says none are applicable you've probably imported a different Fragment class than the one defined by Android/Support Library.

    Check your imports.

    0 讨论(0)
提交回复
热议问题