Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EditText setError() with no message just the icon

Currently I have a really simple code that validates EditText fields and when the user hits the button at the end it checks them. It will put errors in all the fields with this:

if (!emailmatcher.matches()) {     email.setError("Invalid Email");   } if (!zipmatcher.matches()) {     zipcode.setError("Invalid ZipCode");                      } 

My problem that is the keyboard will popup and will move the error bubble to a random place. I was hoping to not have a error bubbles with a message but keep the error icons in invalid EditText fields. I tried inputting setError(null) but that doesn't work. Any Ideas?

like image 278
Nick Avatar asked Jun 30 '11 17:06

Nick


People also ask

How do I add an icon to EditText?

2- First thing we need to do is to look for icons that we can use them for the android edittext. Right click on res folder → New → Vector Asset . Adjust the size from (24dp x 24dp) to (18dp x 18dp), choose the icon that you want by clicking on the android icon, click “Next” button and then click “Finish”.

How do you make EditText not selectable?

EditText editText=(EditText)findViewById(R. id. editText); editText. setTextIsSelectable(false);

How do you make EditText Uneditable?

In your xml code set focusable="false" , android:clickable="false" and android:cursorVisible="false" and this will make your EditText treat like non editable.


1 Answers

Your code perfect to show icon only.

As EditText is show anything related to when it has focused. So just change your code to like that...

if (!emailmatcher.matches()) {     email.requestFocus();     email.setError("Invalid Email");   } if (!zipmatcher.matches()) {     zipcode.requestFocus();     zipcode.setError("Invalid ZipCode");                      } 
like image 196
Tofeeq Ahmad Avatar answered Oct 14 '22 19:10

Tofeeq Ahmad