【发布时间】:2011-08-21 12:55:14
【问题描述】:
我在 FrameLayout 上创建了两个视图,并请求将焦点放在第二个。当我开始活动时,触摸事件会挂起一段时间,然后传递到我的 GL 视图。我认为这需要随机时间(通常为 5-10 秒)。有办法刷新事件队列吗?
我有一个 GLSurfaceView,我想在它上面绘制一个覆盖 SurfaceView。 SurfaceView 必须绘制在 GLSurfaceView 之上,但输入事件必须传递到 opengl 表面。
这是我的活动,
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mGLView= new SFView(this);
mCanvas= new SFCanvas(this);
mLayout=new FrameLayout(this);
mLayout.addView(mCanvas);
mLayout.addView(mGLView);
setContentView(mLayout);
mGLView.post(new Runnable() {
public void run() {
while( mGLView.isFocused() == false )
{
mGLView.requestFocus();
}
}
});
}
我的 Logcat 看起来像这样。
KeyInputQueue Enqueueing touch event1
KeyInputQueue Enqueueing touch event0
KeyInputQueue Enqueueing touch event1
KeyInputQueue Enqueueing touch event0
KeyInputQueue Enqueueing touch event1
KeyInputQueue Enqueueing touch event0
..
WindowManager Delivering pointer 1 > Window{com.myapplication/com.myapplication.activity}
WindowManager Delivering pointer 0 > Window{com.myapplication/com.myapplication.activity}
WindowManager Delivering pointer 1 > Window{com.myapplication/com.myapplication.activity}
KeyInputQueue Enqueueing touch event0
WindowManager Delivering pointer 0 > Window{com.myapplication/com.myapplication.activity}
KeyInputQueue Enqueueing touch event1
WindowManager Delivering pointer 1 > Window{com.myapplication/com.myapplication.activity}
..
我也试过一个 requestFocus() ,但效果相同 应用程序在活动开始的第一秒变得不负责任。我哪里错了? 感谢所有建议。 对于我的错误解释和我的语言,我很抱歉。我是android平台和这个网站的新手。
【问题讨论】:
-
我还重新实现了
onTouchEvent(),两个视图都没有调用这个方法。
标签: android events focus overlay