I use the Jake Wharton ViewPagerIndicator in my FragmentActivity, which contains a viewpager. I find it hard to catch onTouch events. I know that the ViewPagerIndicator captures all touch events to the ViewPager, but I was not successful with setting the onTouchListener for my ViewPager or my ViewIndicator. Here is my main 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() {
....
}
Thank you for your help, I'm sure this is something stupid, but I was looking for a ton and spent hours doing it and could not work anywhere with it.
And as I said, I 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 without success.
source
share