我有一个空白/空的edittext我想知道“退格监听器”或“计数零监听器”现在使用addTextChangedListener()但是当按下backSpace键时没有任何方法被执行,因为它已经是空的
editText.addTextChangedListener(new TextWatcher() {
@Override
public void afterTextChanged(Editable s) {}
@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() != 0)
Field2.setText("");
}
});
答案 0 :(得分:0)
我认为你使用TextWatcher
mEditText.setOnKeyListener(new OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_DEL){
//on backspace
}
return false
}
});