Data Validation and Error Handling
This lesson will cover how to validate user input text and show error messages.
We'll cover the following...
We'll cover the following...
View binding #
To interact with views we need to bind the view from XML to Java objects via the findViewById method.
Note: You can only start binding views after the activity has been created and the content view has been set.
Validation & error message #
To perform validation, we need to set a click listener on the login button via the setOnClickListener method, which accepts the OnClickListener interface as a parameter. When the login button is clicked, we execute our onLoginClicked method.
Click listener can be slightly simplified to lambda because we use Java 8.
Now, we can implement ...