SurfaceView 间取得焦点

在SurfaceView中我们的onKeyDown虽然重写了view的函数, 但一定需要我们在初始化的时候去声明焦点

//添加这个来取得按健事件
this.setFocusable(true);
this.setFocusableInTouchMode(true);
this.requestFocus();

如果这些方法,会造成按键无效,提示No keyboard for id..
只要在初始化时取得焦点才可以调用onKeyDown方法

原文地址:https://www.cnblogs.com/whtydn/p/2501556.html