本帖最后由 xingye109 于 2011-06-13 10:51:11 编辑

解决方案 »

  1.   

    屏蔽掉Activity的onTouchEvent事件,监听mView的onTouchEvent时间或直接在myView类里面重写onTouchEvent方法   public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(new myView(this));       myView mView=new myView(this);
        setContentView(mView); 
        mView.setOnTouchListener(new View.OnTouchListener() {

    @Override
    public boolean onTouch(View v, MotionEvent event) {
    // TODO Auto-generated method stub
     int x = (int)event.getX();
        int y = (int)event.getY();
            
        if(rKeyLeft.contains(x, y)){
            Toast.makeText(DrawTest.this, "x = " + x+"," + "y = " + y,Toast.LENGTH_SHORT).show();
            System.out.println("left");
        }
        if(rKeyRight.contains(x,y)){
            Toast.makeText(DrawTest.this, "x = " + x+"," + "y = " + y,Toast.LENGTH_SHORT).show();
            System.out.println("right");
        }

    return false;
    }
    });}