android - 适配器中无法识别 Kotlin 扩展

标签 android android-recyclerview kotlin

我有毕加索的基本扩展工具:

public val Context.picasso: Picasso 
get() = Picasso.with(this)

public fun ImageView.load(path: String, request: (RequestCreator) -> RequestCreator) {
    request(context.picasso.load(path)).into(this)
}

当我尝试从适配器中的 ImageView 上下文调用它时,它无法被识别。

enter image description here

与 itemView.context.picasso 相同

谢谢!

最佳答案

我很确定您的扩展超出了范围(在不同的包中)。 像这样导入你的扩展:

import your.package.picasso
import your.package.load

看看the docs了解更多信息。

关于android - 适配器中无法识别 Kotlin 扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33658164/

相关文章:

kotlin - ForkJoinPool 和 Kotlin 协程

android - 通过滚动回收器 View 折叠标题图像

java - RecyclerView onScrolled 根本没有被触发

android - 只有创建 View 层次结构的原始线程才能触及它的 View 。更新然后崩溃

java - PKCS1-padding/RSA 加密 ios objc 和 java 的区别

android - 如何使用 DiffUtil 更新 RecyclerView 适配器

Firebase 实时数据库 - 如何使用 REST API 管理数据库规则

没有 ContentProvider 的 Android Sqlite

android - 相机捕获自定义 View Android

安卓 : Cdata in xml not parsing correctly(sax)