private boolean touching;
private float touchTime;
private float distance =200;//滑动距离
private float time =1000;//按下抬起时间1s
private static float distanceLeft =200;//点击位置距离屏幕左侧的距离
private View.OnTouchListeneronTouchListener =new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
if (event.getX()){
touching =true;
touchDownX = event.getX();
touchTime = System.currentTimeMillis();
}else {
return false;
}
break;
case MotionEvent.ACTION_UP:
if (!touching) {
return false;
}
if (System.currentTimeMillis() -touchTime >time) {
return false;
}
if (event.getX() -touchDownX >distance) {
Log.i("wanan","滑动了");
}
touching =false;
break;
}
return true;
}
};