1
我正在使用手势来捕获触摸事件,但它在我长按时触发两个事件。 当我按下按钮时,如何禁用onDown事件? 这是我的代码。Android手势检测器onLongPress和onDown
final GestureDetector gestureDetector = new GestureDetector(
new GestureDetector.SimpleOnGestureListener() {
public void onLongPress(MotionEvent e) {
Toast.makeText(mContext,
"long" + position + counter++,
Toast.LENGTH_SHORT).show();
}
public boolean onDown(MotionEvent e) {
Toast.makeText(mContext,
"touch" + position + counter++,
Toast.LENGTH_SHORT).show();
return true;
}
});
category.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return gestureDetector.onTouchEvent(event);
}
});