开发者

Efficient way to request touch focus from WindowManager?

I have created two views on a FrameLayout, and requested focus to second. When I start the activity touch events hangs up for a while, then passes to my GL view. This takes random time I think (generally 5-10 seconds). It there a way to flush event queue?

I have a GLSurfaceView and I want draw an overlay SurfaceView above it. SurfaceView must be drawn on top of GLSurfaceView but input events must be delivered to opengl surface. This is my activity,

@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 )
     开发者_StackOverflow中文版      {
                mGLView.requestFocus();
           }
        }
    });
}

and my Logcat looks like this.

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}
..

I've also tried a single requestFocus() , but it gave same effect Application becomes irresponsible at first seconds activity starts. Where did I wrong? Thanks for all suggestions. I am sorry for misexplanation, and for my language. I am a newbie for android platform, and this site.


I have found the mistake I did. I was loading resources in views constructor. It was blocking android to doing stuff. I've migrated resource loading into a child thread and problem fixed, a little.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜