How to edittext validation in android

For field validation  we generally use "alert dialog" in android.

An alternative method for this is use default feature and by using this we can easily valiadate a field.The property is"setError".



-------------------------------------------

EditText etUsername;

then

 etUsername.setError("Enter your Username";