Adding validation
Any nontrivial app will have some level of the validation required. The POIApp
app is somewhat trivial, but we have a small set of rules we need to enforce that will facilitate the discussion:
Property |
Rule |
---|---|
|
This cannot be empty or null |
|
This contains a valid decimal number between |
|
This contains a valid decimal number between |
Using the EditText.Error property
The EditText
widget has a string property named Error
, which simplifies the effort of displaying errors to the user, particularly if you want to be able to show all the fields with errors at once. The following screenshot displays the error received for leaving the Name field empty:
To use this facility, simply ...
Get Xamarin Mobile Application Development for Android - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.