Skip to content

Commit

Permalink
匿名内部类Kotlin对比实现
Browse files Browse the repository at this point in the history
  • Loading branch information
BetterZhang committed Jun 28, 2017
1 parent 6a58dd0 commit 809721f
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/com/betterzhang/learnkotlin/kotlin/View.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.betterzhang.learnkotlin.kotlin

/**
* Created by IntelliJ IDEA.
* Author : Andrew Zhang
* Email : betterzhang.dev@gmail.com
* Time : 2017/06/28 上午 11:01
* Desc : 匿名内部类
*/

interface OnClickListener {
fun onClick()
}

class View {

var listener: OnClickListener? = null

fun setOnClickListener(listener: OnClickListener) {
this.listener = listener
}

}

fun main(args: Array<String>) {
val view = View()
view.setOnClickListener(object: OnClickListener {
override fun onClick() {
TODO("not implemented")
}
})
}

0 comments on commit 809721f

Please sign in to comment.