0
The thing is, I’m having trouble finding out if the user typed something into EditorText
. What I want is that, each character, number or letter that the user type, I can perform an action, soon after.
I researched a lot, I did several tests but could not because I am new in android. From what I understand, there are 2 functions that MAYBE I can use:
Using the setOnEditorActionListener:
private EditText valor;
protected void onCreate(Bundle savedInstanceState) {
valor = findViewById(R.id.valor);
valor.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
if(digitou algo){
System.out.println("DIGITOU!");
}
return false;
}
});
}
Using the setOnKeyListener:
valor.setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View view, int i, KeyEvent keyEvent) {
if(digitou algo){
System.out.println("DIGITOU!");
}
return false;
}
});
It is possible to do this?
That’s exactly what I needed. Thank you. More specifically
onTextChanged
because each character pressed it will do the same action. Hug!– Andrei Coelho