Thursday, August 31, 2017

Android Validation Inside Custom Alert Dialog Builder



In a development process, Alert Dialog usually used for show a message from a running process. The message usually show as an error message, success message or notification message.

Custom Alert Dialog Validation

There are two Dialog that much used, they are AlertDialog and Dialog. Both can used for display a message.   You also able to modify the view inside AlertDialog or Dialog. For custom Dialog view, please read here : Android Custom Popup Using AlertDialog And Dialog

Cannot create a validation on EditText inside AlertDialog


My experience using custom alert Dialog is i can't create a validation form and use setError() for EditText. It's because i wrote my validation inside alertDialog.setPositiveButton(). If we need to create a validation, it should outside of that area.

Recommended : Create rating and review look like google play store

Then how to do validation? Here it is, If you need to create a validation inside a custom AlertDialogBuilder, then please use the following code (at least works perfectly in my project):
Ok that's all a little explanation about how to do validation inside a custom Alert Dialog Builder. Hope it helps. Thank you.

Related Posts


EmoticonEmoticon