Reputation: 105
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?
Upvotes: 4
Views: 4975
Reputation: 157467
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.
Upvotes: 5
Reputation: 48272
Android does not support lambdas. Android Studio does this so the code looks like the latest Java.
Upvotes: 2