I have a program where i have an editText . I want to implement TextWatcher to reflect the changes in the total edittext. I want to show the alert dialog when editbox reach the max character limit 10. When i implement Text watcher it works but it show two alert box when it reach 10 character. here is my code
private TextWatcher mTextEditorWatcher = new TextWatcher() {
    public void beforeTextChanged(CharSequence s, int start, int count,
            int after) {
    }
    public void onTextChanged(CharSequence s, int start, int before,
            int count) {
        // This sets a textview to the current length
        // mTextView.setText(String.valueOf(s.length()));
    }
    public void afterTextChanged(Editable s) {
        if (s.length() == 10) {
            messageBody.setImeOptions(EditorInfo.IME_ACTION_DONE);
            AlertDialog.Builder alert = new AlertDialog.Builder(
                    SendSms.this);
            alert.setMessage("You Cross the limit of 10 Words !");
            alert.setPositiveButton("OK",
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog,
                                int whichButton) {
                        }
                    });
            alert.show();
        }
    }
};