我有一個支持多點觸控的項目。當你觸摸一個按鈕時,它會通過1.但是,它只能獲得第一次觸摸。請幫助我,這是我們的論文。多點觸控問題android
這裏是我的代碼:
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";
}
}
}
在這裏
當按鈕1和按鈕2按下它應該通過B1 = 1和B2 = 1但它僅經過B1 = 1。
您是否將此偵聽器附加到所有按鈕上?此外,似乎在代碼中遺漏了return語句。 – sandrstar