In this recipe, we are going to explore the concept of lambdas and closures. We are going to write part of an Android application code responsible for handling button-click actions.
Working effectively with lambda expressions
Getting ready
In order to implement this recipe's code, you need to create a new Android application project using Android Studio IDE.
Let's assume we have the following class, which is a sort of a controller of the application view layer:
class RegistrationScreen : Activity() {
private val submitButton: Button by lazy { findViewById(R.id.submit_button) }
override fun onCreate(savedInstanceState: Bundle?) {
// hook function called once the screen is displayed
}
}
It contains...