alert_ed = (EditText) a.findViewById(R.id.alert_ed_queue_num);
alert_ed.addTextChangedListener(mTextWatcher);
private TextWatcher mTextWatcher = new TextWatcher() { public void afterTextChanged(Editable s) { // 先去掉监听器,否则会出现栈溢出 alert_ed.removeTextChangedListener(mTextWatcher); alert_ed.setText(s.toString().replace("d","")); alert_ed.setSelection(alert_ed.getText().length()); alert_ed.addTextChangedListener(mTextWatcher); } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { } };