Your click event has been intercepted. What works is the viewpagerindicator. Let the viewpagerindicator control not intercept your click event @Override
public boolean dispatchTouchEvent(MotionEvent ev) {
getParent().requestDisallowInterceptTouchEvent(true);
return super.dispatchTouchEvent(ev);
}
Provide a method in fragment1, setOnSwitchFragmentListener(OnSwitchFragmentListener listener, int index);setOnSwitchFragmentListener(OnSwitchFragmentListener listener,int index);
Implement this OnSwitchFragmentListener interface in fragmentParent. 🎜
🎜When the button in fragment1 is clicked, callback this listner, pass the click event to fragmentParent, and then setCurrentItem() . 🎜
Call the
viewpager
的setCurrentItem()
method.Your click event has been intercepted. What works is the viewpagerindicator. Let the viewpagerindicator control not intercept your click event
@Override
Try it
Provide a method in fragment1,
setOnSwitchFragmentListener(OnSwitchFragmentListener listener, int index)
;setOnSwitchFragmentListener(OnSwitchFragmentListener listener,int index)
;在fragmentParent中实现这个
OnSwitchFragmentListener
接口。
Implement thisfragment1
中点击按钮的时候回调这个listner
,把点击事件传递给fragmentParent
,再setCurrentItem()
OnSwitchFragmentListener
interface in fragmentParent. 🎜 🎜When the button infragment1
is clicked, callback thislistner
, pass the click event tofragmentParent
, and thensetCurrentItem()
. 🎜