我有EditText
面具“## - ###。###”,结果是11-111.111,所以我决定使用TextWatch,所以我做了..
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) {
}
});
哪个会使用WebService,但仅用于测试,带有OK消息的Toast执行两次,我不知道为什么......
答案 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();
}
}
});