Android ViewPager's event conflict solution
When I swiped the picture in the viewpager yesterday, I found that the picture did not slide, but the viewpager slides. Later, I checked the information online to resolve the issue of incident conflict.
@Override public boolean dispatchTouchEvent(MotionEvent ev) { // Handle event conflicts with Viewpager if (mCurArrayMode==1){ getParent().requestDisallowInterceptTouchEvent(true); } return (ev); }
The child view in the viewpager overrides dispatchTouchEvent(), and then uses an if statement, and executes the condition when it meets the condition.getParent().requestDisallowInterceptTouchEvent(true);,This tells the parent container to handle events by itself, and the parent container should not be blocked. That's all.
Thank you for reading, I hope it can help you. Thank you for your support for this site!