I want to show error if the user enters blank value in the edittext.But i am not getting the way how could i do this .This is how i want like this:
You have written your code in onClick event. This will call when you click on EditText. But this is something like you are checking it before entering.
So what my suggestion is, you should use focus changed. When any view get focus, you are setting no error and when focus changed, you check whether there is valid input or not like below.
firstName.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View arg0, boolean arg1) {
firstName.setError(null);
if (firstName.getText().toString().trim().equalsIgnoreCase("")) {
firstName.setError("Enter FirstName");
}
}
});