我有一个子类视图,当它在onTouchEvent中收到"修饰"时弹出键盘.它通过请求焦点,检索InputMethodManager,然后调用showSoftInput来显示此信息.
现在我需要弄清楚如何在按下它们时捕获软键盘的敲击字母.我目前只在软键盘上按下"下一个/完成"按钮时得到响应.
这是我的班级:
public class BigGrid extends View {
private static final String TAG = "BigGrid";
public BigGrid(Context context) {
super(context);
setFocusableInTouchMode(true); // allows the keyboard to pop up on
// touch down
setOnKeyListener(new OnKeyListener() {
public boolean onKey(View v, int keyCode, KeyEvent event) {
Log.d(TAG, "onKeyListener");
if (event.getAction() == KeyEvent.ACTION_DOWN) {
// Perform action on key press
Log.d(TAG, "ACTION_DOWN");
return true;
}
return false;
}
});
}
@Override
public boolean onTouchEvent(MotionEvent event) {
super.onTouchEvent(event);
Log.d(TAG, "onTOUCH");
if …
Run Code Online (Sandbox Code Playgroud) android ×1