Custom setError and clearError for any EditText/TextView in android activity

by Thursday, March 20, 2014 0 comments
Customize setError with common function to use it in any actvity.

 public void setError(EditText edit,String str){  
      int resId = this.getResources().getIdentifier(str, "string", this.getPackageName());  
      String msg = getResources().getString(resId);  
      edit.setFocusableInTouchMode(true);  
      edit.requestFocus();  
      edit.setError(msg);  
 }  


To clear error from EditText / TextView use this

 public void clearError(EditText edit){  
      edit.setError(null);  
      edit.clearFocus();  
 }  

karthik nagarajan

Androider

Welcome to Android-Action Blog. I’m a normal guy, who is passionate about Mobile Coding. Here I am writing about Android. Happy learning

0 comments:

Post a Comment