Android 开发使用lambda实现< JDK8兼容

代码精简无疑是每个程序员的目标,简短易读。java 8中的lambda表达式的使用:

4 easy steps

  1. Download and install jdk8.
  2. Add the following to your project’s main build.gradle
buildscript {
  repositories {
     mavenCentral()
  }

  dependencies {
     classpath 'me.tatarka:gradle-retrolambda:3.2.3'
  }
}

  

3. Now add this to your application module’s build.gradle
apply plugin: 'com.android.application' // or apply plugin: 'java'
apply plugin: 'me.tatarka.retrolambda'

  

4. Add these lines to your application module’s build.gradle to inform the IDE of the language level:

android {
  compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
  }
}

  



开始愉快的👟精简的代码吧
from: https://medium.com/android-news/retrolambda-on-android-191cc8151f85#.4ce4wqq1i
posted @ 2016-02-26 09:37  狂奔的小狮子  阅读(574)  评论(0编辑  收藏  举报