-1

I'm trying to use multitouch as a method to press 2 things simultaneously.

Here's my Code:

TouchHandle.setOnTouchListener(new OnTouchListener () {
              public boolean onTouch(View view, MotionEvent event) {
                  int actions = event.getActionMasked();
                  switch (actions)
                  {
                  case MotionEvent.ACTION_DOWN:

                  case MotionEvent.ACTION_POINTER_DOWN:
                      SendKeyCode(Server, "keydec.down");
                  case MotionEvent.ACTION_POINTER_UP:
                      SendKeyCode(Server, "keydec.up");
                  case MotionEvent.ACTION_UP:

                  }
              return true;
                  }
        });

The problem is that when I touch the screen, the server is retrieving "keydec.down" and "keydec.up" even thought I haven't removed my finger yet from the touchscreen. So the View TouchHandle is detecting an ACTION_POINTER_DOWN and ACTION_POINTER_UP when my finger touches the screen even if I haven't pulled my finger up yet. Any thoughts?

4

1 に答える 1

1
int actions = event.getAction();
switch (actions)
                  {
                  case MotionEvent.ACTION_DOWN:
                  break;
                  case MotionEvent.ACTION_POINTER_DOWN:
                      SendKeyCode(Server, "keydec.down");
                  break;
                  case MotionEvent.ACTION_POINTER_UP:
                      SendKeyCode(Server, "keydec.up");
                  break;
                  case MotionEvent.ACTION_UP:
                  break;

                  }

You should use breaks between cases. And i also think that these MotionEvent constants might work with event.getAction() try that one.

于 2012-09-13T19:28:49.803 に答える