MyViewPage.java 794 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package com.cooleshow.base.widgets;
  2. import android.content.Context;
  3. import android.util.AttributeSet;
  4. import android.view.MotionEvent;
  5. import androidx.viewpager.widget.ViewPager;
  6. /**
  7. * 创建日期:2022/5/24 17:54
  8. *
  9. * @author Ryan
  10. * 类说明:
  11. */
  12. public class MyViewPage extends ViewPager {
  13. private boolean willIntercept = true;
  14. public MyViewPage(Context context, AttributeSet attrs) {
  15. super(context, attrs);
  16. // TODO Auto-generated constructor stub
  17. }
  18. @Override
  19. public boolean onInterceptTouchEvent(MotionEvent arg0) {
  20. if (willIntercept) {
  21. return super.onInterceptTouchEvent(arg0);
  22. } else {
  23. return false;
  24. }
  25. }
  26. public void setTouchIntercept(boolean value) {
  27. willIntercept = value;
  28. }
  29. }