I really like Android Studio's code folding for anonymous class:
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
doSomething();
return null;
}
}.execute();
into
(AsyncTask) (params) -> {
doSomething()
}.execute();
This folding option is under "closures" in the settings. I switched to Java 8 (using retrolambda) since I wanted to use lambda expressions, however now Android Studio doesn't fold anonymous class. Is there a way to re-enable it?
PS I know I can stay at Java 7 and Android Studio would fold single-method anonymous class into lambda expression, but I want to be able to type lambda expressions directly, while still have multi-method anonymous class folded.
First you need to set JDK location to java 8 in under project structure -> SDK Location
Right now Android Studio 2.1 does not support lambda notation for java 8 but there is workaround for that.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.