我有一个要监视其KeyEvent的EditText,并且有一个监听器,设置如下:
mText = (EditText) this.findViewById(R.id.title);
mText.setOnKeyListener(new OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
final int view = v.getId();
switch (view) {
case R.id.title:
Log.d(LOG_TAG, "key handled");
break;
}
return false;
}
});
我的问题是,使用虚拟键盘键入EditText时,唯一触发记录的按键是退格键。我已经验证所有其他按键都没有触发
onKey()
。我敢肯定这很简单,但是在SO上没有发现任何似乎可以解决此问题的东西。谢谢,
保罗
最佳答案
尝试使用addTextChangedListener(TextWatcher watcher)
定义的here,它可以处理物理键盘和软键盘。
希望对您有所帮助