{{1}}
}
在此我希望在edittext窗口中按下每个键并在单击下一个按钮后出现的下一个窗口中显示它。我想主要使用KEYCODE_DEL监视退格。得到这个的最好方法是什么?由于我是android新手,我觉得很难实现这个。谢谢你提前:) Ovina
答案 0 :(得分:0)
这将有助于您倾听每次按键
editText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
//do what you want
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
//do what you want
}
@Override
public void afterTextChanged(Editable s) {
//do what you want
}
});
但是要检测后空间动作,您必须设置setOnKeyListener
,例如:
editText.setOnKeyListener(new OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
//You can identify which key pressed buy checking keyCode value with KeyEvent.KEYCODE_
if(keyCode == KeyEvent.KEYCODE_DEL){
//this is for backspace
}
return false;
}
});