if (yMoved || xMoved) {
clickCount = 0;
firstClickTime = 0;
}
}
}
}
使用实例:
[java]
private DoubleClick doubleClick;
//当需要使用双击事件监听,调用此方法即可。
protected void enableDClickReturn(){
doubleClick = new DoubleClick(new DoubleClick.OnDoubleClickListener() {
@Override
public void onDoubleClick() {
//这里我的项目需要的功能是双击返回上一级Activity
finish();
}
});
}
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
if(doubleClick == null) {
return super.dispatchTouchEvent(event);
}else{
doubleClick.dispatchTouchEvent(event);
}
return super.dispatchTouchEvent(event);
}
更多关注: