views:

39

answers:

1

Hi, I have 2 EditText widgets ,one takes username and other takes password.When the user enters username in First EditText ,the text should be validated (It should accept only characters no digits) when the focus is on the first EditText. How to achieve this. It needs to display error message using setError() method in EditText when the user enters wrong data.

A: 

Same problem here. Would be interested in an answer... Anyone?

mmo
step1: Activity should implements android.text.TextWatcherstep2:fname.addTextChangedListener(this); (fname is of type EditText)step3:Overridepublic void afterTextChanged(Editable arg0) { String s=fname.getText().toString(); int count=0; if(!s.equals(" ")) { for(int i=0;i<s.length();i++) { if(Character.isDigit(fname.getText().toString().charAt(i))) { //sai fname.setTextColor(Color.RED); fname.setError("Your First Name Should only Contain Letters"); count++; } } } }don
Android_prog