使用TextWatcher
,将EditText的果园计为:
private CharSequence temp;
mEditText = (EditText)findViewById(R.id.ET);
mEditText.addTextChangedListener(mTextWatcher);
TextWatcher mTextWatcher = new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int arg1, int arg2,
int arg3) {
temp = s;
}
@Override
public void onTextChanged(CharSequence s, int arg1, int arg2,
int arg3) {
}
@Override
public void afterTextChanged(Editable s) {
// check here length of text in EditText after change
if (temp.length() > 3) {
// your alertdialog
}
}
};