When erasing a character, how do I do something?

0

I'm using this method to delete the last character typed in a TextView :

texto = txtTexto.getText().toString();
int length = texto.length();  
txtTexto.setText(texto.substring(0, length - 1));

But when I delete a character, I type a point "." , I want it to execute something.

    
asked by anonymous 07.03.2015 / 14:23

1 answer

5

It's not very clear what you want to do, but if you check if the last character is a dot, do:

int length = texto.length();

if (texto.substring(length - 1, length).equals(".")) {
    funcao_qualquer();
}

texto = txtTexto.getText().toString();
txtTexto.setText(texto.substring(0, length - 1));
    
07.03.2015 / 14:45