NAP-Developer
NAP-Developer

Reputation: 3796

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();

Upvotes: 9

Views: 9623

Answers (2)

Aravind Raj
Aravind Raj

Reputation: 11

Example
=======
xml
---
 <EditText
                        android:id="@+id/name"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        />


java
-----
private EditText EditText1;
username = (EditText) findViewById(R.id.name);
username .setError(null);

Upvotes: 0

Ovidiu Latcu
Ovidiu Latcu

Reputation: 72331

You should do the following :

mEditText.setError(null);//removes error
mEditText.clearFocus();

Upvotes: 24

Related Questions