Skip to content

Instantly share code, notes, and snippets.

@ksu3101
Created May 9, 2016 12:56
Show Gist options
  • Save ksu3101/559c3cd033f1b715b44b47b60b487f80 to your computer and use it in GitHub Desktop.
Save ksu3101/559c3cd033f1b715b44b47b60b487f80 to your computer and use it in GitHub Desktop.
public class TextWatcherAdapter
implements TextWatcher {
private final EditText view;
private final TextWatcherListener listener;
public TextWatcherAdapter(EditText editText, TextWatcherListener listener) {
this.view = editText;
this.listener = listener;
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
listener.onTextChanged(view, s.toString());
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
// pass
}
@Override
public void afterTextChanged(Editable s) {
// pass
}
public interface TextWatcherListener {
void onTextChanged(EditText view, String text);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment