view -> Log.d(“l”,”log”)
intput 类型
body 类型
具体参见:https://github.com/evant/gradle-retrolambda
apply plugin: 'com.android.application'
apply plugin:'me.tatarka.retrolambda'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'me.tatarka:gradle-retrolambda:3.2.5'
}
}
// Required because retrolambda is on maven central
repositories {
mavenCentral()
}
3.在 build.gradle(Module) 中添加一下部分
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Log.d("onClick", "onClick");
}
});
button.setOnClickListener(view->Log.d("onClick", "onClick"));