How to Apply the Textchange event on EditText

i think the best in case the edittext type is number... use the (length function) of parameter instead of (equle() function) ex:

edittext.addTextChangedListener(new TextWatcher() {

    public void onTextChanged(CharSequence s, int start, int before,
            int count) {
        if (s.length() > 0)
                { //do your work here }
        }

    }

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

    }

    public void afterTextChanged(Editable s) {

    }
});

I think you are receiving empty String " " which is causing this problem. Make sure you get a non-empty String from your EditText.

Consider your EditText doesn't have any value typed in, and you are trying to get its value and convert into int you will run into this kind of problem.

edittext.addTextChangedListener(new TextWatcher() {

    public void onTextChanged(CharSequence s, int start, int before,
            int count) {
            if(!s.equals("") ) { 
                //do your work here 
            }
    }



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

    }

    public void afterTextChanged(Editable s) {

    }
});

Also check this link for more idea,

https://stackoverflow.com/a/3377648/603744