0

I have a EditText with a Mask "##-###.###" and the result is 11-111.111, so I decided to use a TextWatch, so I did..

cepFrom.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if(s.length() == 10){
                //getCepFrom(s.toString());
                Toast.makeText(DetalhesProdutos.this, "OK", Toast.LENGTH_SHORT).show();
            }
        }

        @Override
        public void afterTextChanged(Editable s) {

        }
    });

Which will consume a WebService, but just for testing, the Toast with the OK message, executes twice and I dont' know why...

Suraj Makhija
  • 1,376
  • 8
  • 16

1 Answers1

0
   cepFrom.addTextChangedListener(new TextWatcher() {
    @Override
    public void beforeTextChanged(CharSequence s, int start, int count, int after) {

    }

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

    }

    @Override
    public void afterTextChanged(Editable s) {
     if(cepFrom.getText().length() == 10){
            //getCepFrom(s.toString());
            Toast.makeText(DetalhesProdutos.this, "OK", Toast.LENGTH_SHORT).show();
        }
    }
});
sasikumar
  • 12,540
  • 3
  • 28
  • 48