Skip to content Skip to sidebar Skip to footer

How To Validate Edit Text Input In Android?

I've added input validation to a set of edit texts in a dialog message using the setError method in Android. But when I test it by leaving some of the edit texts blank and clicking

Solution 1:

That's because you are calling dialog.cancel() irrespective of error(s). Call this method only if there is no error. Keep a track of error using a boolean. If error exist make it false otherwise keep it true and call the dialog.cancel() method only if the boolean is true.


Post a Comment for "How To Validate Edit Text Input In Android?"