首先是配置。。。
在project的build.gradle中添加
classpath 'me.tatarka:gradle-retrolambda:3.2.0'
在module的build.gradle中添加
//设置JDK1.8
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
jackOptions {
enabled true
}
位置如下:
哈哈哈,接下来就开始我们的lamda之旅啦。。。
MainActivity.class
public class MainActivity extends AppCompatActivity {
private static final String TAG = "cwy";
/**
* ATTENTION: This was auto-generated to implement the App Indexing API.
* See https://g.co/AppIndexing/AndroidStudio for more information.
*/
private GoogleApiClient client;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
findViewById(R.id.button1).setOnClickListener(view -> onButton1());
findViewById(R.id.button2).setOnClickListener(view -> onButton2());
findViewById(R.id.button3).setOnClickListener(view -> onButton3());
findViewById(R.id.button4).setOnClickListener(view -> onButton4());
findViewById(R.id.button5).setOnClickListener(view -> onButton5());
findViewById(R