Skip to content

Instantly share code, notes, and snippets.

@danielsotopino
Last active October 7, 2015 19:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielsotopino/eae7587842d355cdbc74 to your computer and use it in GitHub Desktop.
Save danielsotopino/eae7587842d355cdbc74 to your computer and use it in GitHub Desktop.
[Android] Replace EditText text on user input.
editText.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start,
int before, int count) {
}
@Override
public void beforeTextChanged(CharSequence s, int start,
int count, int after) {
}
@Override
public void afterTextChanged(Editable s) {
idAnswerEditText.removeTextChangedListener(this);
String someString = StringUtil.doSomething(s.toString());
idAnswerEditText.getText().clear();
idAnswerEditText.getText().append(someString);
idAnswerEditText.setSelection(someString.length());
idAnswerEditText.addTextChangedListener(this);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment