修改build.gradle(Module)文件
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.maimiho.androidtest"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
jackOptions {
enabled true
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {//指定java版本
sourceCompatibility 1.8
targetCompatibility 1.8
}
}
增加的内容如下:
defaultConfig{
jackOptions {
enabled true
}
}
compileOptions {//指定java版本
sourceCompatibility 1.8
targetCompatibility 1.8
}
就可以支持Lambda表达式等特性了
button.setOnClickListener(v -> Toast.makeText(this, "click", Toast.LENGTH_SHORT).show())