Search code examples
androidandroid-studiofolding

What does "(v) ->" mean in Android Studio?


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?

enter image description here


Solution

  • 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.