Kotlin:Interface … does not have constructors

接口

interface OnSchoolItemClickListener {
    fun onItemClick(pos: Int, name: String)
}

定义变量实现接口报错:

这是从java转kotlin后的

Interface … does not have constructors

正确姿势

private val listener = object : OnSchoolItemClickListener {
    override fun onItemClick(pos: Int, name: String) {
        setSchoolText(name)
        hideBottom()
    }
}

参考:Kotlin: Interface … does not have constructors

阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_37299249/article/details/79946269
个人分类: DIARY
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭