Intercepting touch events in ViewPagerIndicator

我只是一个虾纸丫 提交于 2020-01-30 09:41:46

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!