小编Bak*_*ser的帖子

Kotlin 自定义 OnClickListener 接口

我在学习 Kotlin 时在Udacity 项目中遇到了这个自定义 OnClickListener 接口。我明白它在做什么,但我不明白它是如何做到的。有人可以向我解释一下代码吗?

/**
 * Custom listener that handles clicks on [RecyclerView] items.  Passes the [MarsProperty]
 * associated with the current item to the [onClick] function.
 * @param clickListener lambda that will be called with the current [MarsProperty]
 */
class OnClickListener(val clickListener: (marsProperty:MarsProperty) -> Unit) {
    fun onClick(marsProperty:MarsProperty) = clickListener(marsProperty)
}
Run Code Online (Sandbox Code Playgroud)

android kotlin

1
推荐指数
1
解决办法
2962
查看次数

标签 统计

android ×1

kotlin ×1