软件盘的监听事件,如下
private final OnKeyListener mSubjectKeyListener = new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getAction() != KeyEvent.ACTION_DOWN) { return false; } // When the subject editor is empty, press "DEL" to hide the input field. if ((keyCode == KeyEvent.KEYCODE_DEL) && (mSubjectTextEditor.length() == 0)) { /* Vanzo:zhangshuli on: Thu, 05 Mar 2015 10:26:59 +0000 showSubjectEditor(false); */ // End of Vanzo: zhangshuli mWorkingMessage.setSubject(null, true); /// M: add for character counter updateCounter(mWorkingMessage.getText(), 0, 0, 0); return true; } return false; } };
然后我们看一下调用的地方
mSubjectTextEditor = (EditText)findViewById(R.id.subject); mSubjectTextEditor.setOnKeyListener(show ? mSubjectKeyListener : null);
所以,我们可以得出的结论就是,一些控件本身就是监听软件盘的功能。
时间: 2024-10-05 05:26:40