Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created August 7, 2019 17:42
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 parzibyte/e3cb8cdc66203c1da0908b302399bdc6 to your computer and use it in GitHub Desktop.
Save parzibyte/e3cb8cdc66203c1da0908b302399bdc6 to your computer and use it in GitHub Desktop.
editTextBusqueda.addTextChangedListener(new TextWatcher() {
// Antes de que el texto cambie (no debemos modificar nada aquí)
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
//Cuando esté cambiando...(no debemos modificar el texto aquí)
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
/*
* Aquí el texto ya ha cambiado completamente, tenemos el texto actualizado en pocas palabras
*
* Por cierto, aquí sí podemos modificar el texto pero debemos tener cuidado para no caer en
* un ciclo infinito
* */
@Override
public void afterTextChanged(Editable s) {
String elNuevoTexto = s.toString();
// Hacer lo que sea con elNuevoTexto
Toast.makeText(getApplicationContext(), "Cambió a " + elNuevoTexto, Toast.LENGTH_SHORT).show();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment