I got "anonymous new runnable() can be replaced with lambda" warning with 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 re-write 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 run application, Android Studio stops with 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 can't understand why Android Studio let me use lambda expression even though it can't compile. Is it a bug?
Also, I tried to use gradle-retrolambda, but it is hard to use for biginner.
As I can't compile my code, I'm not sure above lambda expresssion is correct or not.
In my opinion, IDE should not complain about the code can't be compiled. So I think the warning to use lambda expression should be suppressed. But I don't know how can it be...
Any help is appreciated.