prongs prongs - 4 months ago 12x
Android Question

android edittext onchange listener

I know a little bit about

but that fires on every character you enter. I want a listener that fires whenever the user finishes editing. Is it possible? Also in
I get an instance of
but I need an instance of
. How do I get that?

EDIT: the second question is more important. Please answer that.


first, you can see if the user finished to edit the text if the EditText lose focus or if the user presses done button (this depends on your implementation and on what fits the best for you). Second, you can't get an EditText instance within the textwatcher only if you have declared the EditText as a instance object. Even though you shouldn't edit the EditText within the textwatcher because it is not safe.


To be able to get the EditText instance into your TextWatcher implementation you should try something like this:

public class YourClass extends Activity {

 private EditText yourEditText;

    public void onCreate(Bundle savedInstanceState) {

        yourEditText = (EditText) findViewById(;

        yourEditText.addTextChangedListener(new TextWatcher() {

          public void afterTextChanged(Editable s) {

            // you can call or do what you want with your EditText here
            yourEditText. ... 


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

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


Note that the above sample might have some errors but I just wanted to show you an example.