How do I create an event when someone types something in Edittext?

Asked

Viewed 715 times

3

I would like to create an event as the user enters some word in my EditText, but I don’t know how to access it.

1 answer

6


You can use the addTextChangedListener(). See the code below:

seuEditText.addTextChangedListener(new TextWatcher() { 
public void afterTextChanged(Editable s) { 

// Aqui você coloca o evento

} 
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
} 
public void onTextChanged(CharSequence s, int start, int before, int count) {
} 
});

See more details in the documentation.

  • 1

    Excellent, that’s just what I needed. Thank you.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.