I have an XML layout file that contains an EditText and a Button. I would like to display the following validation message to provide feedback to the user:
You must enter 4 numbers
What’s the best way to go about accomplishing this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
From my experience, this is the best way:
The result is:
Also, if the input must be numeric, use
android:inputType="numberSigned"in theEditTextdefinition. That way the device won’t allow the user to put non-numeric values; even better, it will show a special keyboard to do so: