When in Android Studio I will often see my anonymous inner class for a View.onClickListener compressed to a (v)-> until I click on it, much the same way my code will display as if strings are hard-coded when my code uses a string resource id. Google searches for '"(v) ->" android' are not giving me anything. Is this some more advanced compact coding notation that I can use?
It is called lambda expressions, which is a feature of Java 8 and is not yet supported in Android. In your case, it is just the onClick
's View
parameter. It is the android studio to compact anonymous inner classes.
Android does not support lambdas. Android Studio does this so the code looks like the latest Java.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With