I have EditText which displays something like ###-###. I want the user to be able to change this text only from the 1st position onward. That is user should not be able to touch
You need to implement the TextWatcher interface and override the three methods, afterTextChanged, beforeTextChanged, onTextChanged (you may only need to actually use one of them) Eg:
public class MyTextWatcher implements TextWatcher {
@Override
public void afterTextChanged(Editable arg0) {
changeItBack();
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
}
You then add this Watcher to your EditText, like so:
myEditText.addTextChangedListener(new MyTextWatcher());
Hope this helps.