IBu*_*nny 2 android tap double-click
如何检测android中的双击?我实现了OnDoubleTapListener并写了这个:
public boolean onDoubleTapEvent(MotionEvent e) {
// TODO Auto-generated method stub
if(e.getAction() == 1){
Toast.makeText(getApplicationContext(),"Double Tap", Toast.LENGTH_SHORT).show();
}
return true;
}
Run Code Online (Sandbox Code Playgroud)
但它没有用.这有什么不对?
public class GestureDoubleTap extends GestureDetector.SimpleOnGestureListener {
@Override
public boolean onDoubleTap(MotionEvent e) {
//some logic
return true;
}
}
Run Code Online (Sandbox Code Playgroud)
GestureDoubleTap gestureDoubleTap = new GestureDoubleTap();
gestureDetector = new GestureDetector(this/* context */, gestureDoubleTap);
view.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
return gestureDetector.onTouchEvent(motionEvent);
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8480 次 |
| 最近记录: |