0

마스크가 "## - ###. ###"이고 결과는 11-111.111이므로 TextWatch를 사용하기로 결정했습니다. Web 서비스를 소비하지만, 단지 테스트를 위해, 토스트는 OK 메시지와 함께 두 번 실행하고 나는 '왜 몰라합니다유효성 검사 후 TextWatcher가 반복되는 EditText Android

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) { 

     } 
    }); 

...

+0

이동'Toast.makeText (DetalhesProdutos. this, "OK", Toast.LENGTH_SHORT) .show();'afterTextChanged' – rafsanahmad007

+0

반복하기 때문에 반복되는 것처럼 보입니까? –

답변

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(); 
     } 
    } 
}); 
+0

그것의 작동하지 않는, 아직도 두번 토스트 반복! –

+0

토스트에 대한 코드를 넣은 것 같아요. 실수로 확인해보세요. 왜냐하면 그게 저에게 작용하기 때문이죠. – sasikumar

+0

작동하지만, 그 마스크를 제거했을 때 ... –