问题
I am using Jake Wharton's ViewPagerIndicator on my FragmentActivity which contains a viewpager. I am having difficulty intercepting onTouch events. I know the the ViewPagerIndicator intercepts all touch events to the ViewPager, but I have had no success with setting an onTouchListener to either my ViewPager or my ViewIndicator. Here's my basic setup:
public class MainActivity extends FragmentActivity {
mPager = (ViewPager)findViewById(R.id.pager);
adapter = new ViewSliderAdapter(getSupportFragmentManager());
mPager.setAdapter(adapter);PageIndicator mIndicator = (CirclePageIndicator)findViewById(R.id.indicator);
mIndicator.setViewPager(mPager);
mIndicator.setOnPageChangeListener(new OnPageChangeListener() {
....
}
Thanks for your help, I'm sure its something stupid but I've googled a ton and been tinkering with this for hours and can't seem to get anywhere with it.
and As ive said, I've tried things like:
mPager.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
break;
default:
break;
}
return false;
}
});
with both ViewPager and ViewPagerIndicator with no success.
来源:https://stackoverflow.com/questions/17370729/intercepting-touch-events-in-viewpagerindicator