在适配器中不能识别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上下文中调用它时,它不被识别。
与itemView.context.picasso一样的东西
谢谢!
我很确定你的扩展超出了范围(在不同的包中)。 像这样导入你的扩展:
import your.package.picasso import your.package.load
看看文档的更多信息。