Basic Form Validation in Android with Live Data and Data Binding
At some point in your Android career you will have to implement some sort of form. Forms can be incredibly tedious to implement and if done incorrectly can be a frustrating user experience. Of all of the ways I’ve had to program forms, I’ve had the most luck using Live Data. Live Data will help us code a form that has input validation, allows for unit testing, and is not frustrating for a user to use to input their important data.
Setting Up the View
Since we’re not doing anything too fancy, we can just make an EditText with a save Button inside of a LinearLayout. If you’ve done any Android this should look very familiar, but if you’re new it should be easy enough to see what’s happening.
This should render a view that looks like this:
Now that we have the UI lined up, lets focus on connecting it to some logic so we…