android实现双击事件的监听
发表于:2024-11-26 作者:热门IT资讯网编辑
编辑最后更新 2024年11月26日,class onDoubleClick implements View.OnTouchListener{@Overridepublic boolean onTouch(View v, MotionEv
class onDoubleClick implements View.OnTouchListener{
@Override
public boolean onTouch(View v, MotionEvent event) {
if(MotionEvent.ACTION_DOWN == event.getAction()){
count++;
if(count == 1){
firClick = System.currentTimeMillis();
} else if (count == 2){
secClick = System.currentTimeMillis();
if(secClick - firClick < 1000){
//双击事件
}
count = 0;
firClick = 0;
secClick = 0;
}
}
return true;
}
}