I got "anonymous new runnable () can be replaced with lambda" using the following code.
final ScrollView sv = (ScrollView) findViewById(R.id.scrollView); sv.post(new Runnable() { @Override public void run() { sv.fullScroll(ScrollView.FOCUS_DOWN); } });
I searched on Google very hard and seems to be rewriting using lambda expression ...
final ScrollView sv = (ScrollView) findViewById(R.id.scrollView); Runnable test = () -> sv.fullScroll(ScrollView.FOCUS_DOWN); test.run();
But when I try to start the application, Android Studio stops with an error as follows:
Error:(78, 40) error: lambda expressions are not supported in -source 1.7 (use -source 8 or higher to enable lambda expressions)
I cannot understand why Android Studio allows me to use a lambda expression, even if it cannot compile. This is mistake?
Also, I tried to use gradle-retrolambda , but its hard to use for biginner.
Since I cannot compile my code, I am not sure if the above lambda expresssion is correct or not.
In my opinion, the IDE should not complain that the code could not be compiled. Therefore, I think the warning to use the lambda expression should be suppressed. But I do not know how this can be ...
Any help is appreciated.
source share