private ViewPager yuandipage;
通过对viewpage进行设置
setOnTouchListener
yuandipage.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
switch (motionEvent.getAction()){
case MotionEvent.ACTION_DOWN:
//移除所有的消息,不再自动轮播
handler.removeCallbacksAndMessages(null);
break;
case MotionEvent.ACTION_MOVE:
handler.removeCallbacksAndMessages(null);
break;
case MotionEvent.ACTION_UP:
//再次发送消息
handler.sendEmptyMessageDelayed(1,1000);
Log.e("qqq", "onTouch: ACTION_UP" );
break;
case MotionEvent.ACTION_CANCEL:
//再次发送消息
handler.sendEmptyMessageDelayed(1,1000);
Log.e("qqq", "onTouch: ACTION_CANCEL" );
break;
}
//true:自己消费此事件,不再向上传递 false:自己不处理,向上传递
return false;
}
});