因此,我正在开发一个应用程序,并且需要同时按下两个按钮。 我需要在按下时触发按钮的事件(这也是同一时间)。Android多点触控帮助
想象一下一辆车 - 我已经左转,右转,前进和后退。我需要按EG。向前和向右一起右转。
这是我的方法,但由于某种原因,当我按下两个按钮时,只有第一个按下的按钮被触发......任何想法?
// Handle touches of the navigation arrows
public boolean onTouch(View v, MotionEvent theMotion) {
switch (theMotion.getAction()) {
// A button was PRESSED
case MotionEvent.ACTION_DOWN:
switch (v.getId()) { // Which button?
case R.id.freestyle_upArrow: // The upArrow
bt.sendNXTcommand(MOTOR_B_FORWARD, 720);
break;
case R.id.freestyle_downArrow: // The downArrow
bt.sendNXTcommand(MOTOR_B_BACKWARD, 720);
break;
case R.id.freestyle_leftArrow: // The leftArrow
bt.sendNXTcommand(MOTOR_A_LEFT, 720);
break;
case R.id.freestyle_rightArrow: // The rightArrow
bt.sendNXTcommand(MOTOR_A_RIGHT, 720);
break;
}
break;
// A button was RELEASED
case MotionEvent.ACTION_UP:
switch (v.getId()) { // Which button?
case R.id.freestyle_upArrow: // The upArrow
bt.sendNXTcommand(MOTOR_B_STOP, 0);
break;
case R.id.freestyle_downArrow: // The downArrow
bt.sendNXTcommand(MOTOR_B_STOP, 0);
break;
case R.id.freestyle_leftArrow: // The leftArrow
break;
case R.id.freestyle_rightArrow: // The rightArrow
break;
}
break;
}
return true;
}
那么,有什么想法吗?这与我的屏幕允许的点数有关吗?
PHONE规格:三星Galaxy王牌运行Android OS固件2.2.1
问候,
丰富。
感谢所有帮助。 – richard