我对 OnTouchEvent 感到沮丧。我只想检测 5 个手指。我怎样才能做到这一点?问题还在于它多次调用。这是我的代码:
@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
int pointerCount = event.getPointerCount();
System.out.println("My pointer....." + pointerCount);
final int action = event.getAction();
if(action == MotionEvent.ACTION_UP) {
if(pointerCount >= 4){
Log.d("MyActivity", "in onTouchEvent!");
Toast.makeText(MyclassActivity.this, "Finger !!"+pointerCount,Toast.LENGTH_SHORT).show();
Intent z = new Intent(MyclassActivity.this,
DashboardActivity.class);
startActivity(z);
finish();
}
}
return super.onTouchEvent(event);
}
我对这件事不满意。让我在您的帮助下准确计算 5 个手指,并避免多次调用 onTouchevent。
谢谢,