属性委托必须有一个“getValue(MainActivity, KProperty<*>)”方法

时间:2021-08-01 17:14:46

标签: android kotlin

在阅读《Android 编程大书呆子牧场指南第 4 版》一书时,遇到了使用 lazy 时出现错误:Property delegate must have a 'getValue(MainActivity, KProperty<*>)' method. None of the following functions is suitable: public inline operator fun <T> Lazy<QuizViewModel>.getValue(thisRef: Any?, property: KProperty<*>): QuizViewModel defined in kotlin 的问题。

private val quizViewModel: QuizViewModel by lazy {
    ViewModelProvider.(this).get(QuizViewModel::class.java)
}

英语不是我的母语,这是我在stackoverflow上的第一个问题,所以我很抱歉错误

0 个答案:

没有答案