I have my Android studio set with these:
classpath "me.tatarka:gradle-retrolambda:3.2.2"
classpath 'me.tatarka.retrolambda.projectlombok:lombok.ast:0.2.3.a2'
And I am trying to use lambdas to know what I can do or not.
When I did the following code:
alertDialogBuilder.setPositiveButton("Okay", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
The IDE grayed out the new DialogInterface.OnClickListener()
telling me it could be replaced with a lambda. Nothing more or less. After looking into several examples. I tried things like:
alertDialogBuilder.setPositiveButton("Okay", (DialogInterface dialog) -> {
dialog.cancel();
});
Also these:
alertDialogBuilder.setNegativeButton((DialogInterface) d -> d.cancel());
Among the errors:
Error:(99, 64) error: incompatible types: DialogInterface is not a functional interface multiple non-overriding abstract methods found in interface DialogInterface
How should I use lambda in this case?