Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I remove edittext error and request focus in android?

When I set error and request focus on edittext then it sets an error and request focus but how can I remove error and remove focus ?

mEditTextSearchOrAdd.setError("Error");
mEditTextSearchOrAdd.requestFocus();
like image 681
Najib.Nj Avatar asked Nov 02 '12 13:11

Najib.Nj


People also ask

How do I clear focus in EditText?

Remove focus but remain focusable: editText. setFocusableInTouchMode(false); editText. setFocusable(false); editText.

How can I tell if EditText has focus android?

You can use View. OnFocusChangeListener to detect if any view (edittext) gained or lost focus. This goes in your activity or fragment or wherever you have the EditTexts.

How do I remove Textinputlayout error?

Now you can simply do input. setError(..) for new error and input. setErrorEnabled(false) to remove it.


1 Answers

You should do the following :

mEditText.setError(null);//removes error
mEditText.clearFocus();
like image 186
Ovidiu Latcu Avatar answered Sep 21 '22 03:09

Ovidiu Latcu