我有一个支持多点触控的项目。当您触摸一个按钮时,它会传递 1。但是,它只获得第一次 touch 。请帮助我,这是为了我们的论文。
这是我的代码:
public boolean onTouch(View v, MotionEvent event) {
int action = event.getActionMasked();
if(action == MotionEvent.ACTION_DOWN){
b1=b2=b3=b4=b5=b6="0";
switch(v.getId()) {
case R.id.button3:
b3 = "1";
break;
case R.id.button2:
b2 = "1";
break;
case R.id.button1:
b1 = "1";
break;
case R.id.button4:
b4 = "1";
break;
case R.id.button5:
b5 = "1";
break;
case R.id.button6:
b6 = "1";
}
} else if(action == MotionEvent.ACTION_POINTER_DOWN )
{
switch(v.getId()) {
case R.id.button3:
b3 = "1";
break;
case R.id.button2:
b2 = "1";
break;
case R.id.button1:
b1 = "1";
break;
case R.id.button4:
b4 = "1";
break;
case R.id.button5:
b5 = "1";
break;
case R.id.button6:
b6 = "1";
}
}
}
在这里,当按下 button1 和 button2 时,它应该传递 b1=1 和 b2=1,但它只传递 b1=1。