安卓dispatchtouchevent怎么拦截双击事件
1个回答
展开全部
// 解决用户连续点击造成出现多个相同的activity
public long lastClickTime = 0;
public boolean isFastDoubleClick() {
long time = System.currentTimeMillis();
long timeD = time - lastClickTime;
if (timeD >= 0 && timeD <= 500) {
return true;
} else {
lastClickTime = time;
return false;
}
}
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
if (isFastDoubleClick()) {
return true;
}
}
return super.dispatchTouchEvent(ev);
}
public long lastClickTime = 0;
public boolean isFastDoubleClick() {
long time = System.currentTimeMillis();
long timeD = time - lastClickTime;
if (timeD >= 0 && timeD <= 500) {
return true;
} else {
lastClickTime = time;
return false;
}
}
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
if (isFastDoubleClick()) {
return true;
}
}
return super.dispatchTouchEvent(ev);
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询