GithubHelp home page GithubHelp logo

Comments (11)

gzsll avatar gzsll commented on June 14, 2024 1

可以修改LoopViewPager ,先添加

private boolean isCanScroll = true;

    public boolean isCanScroll() {
        return isCanScroll;
    }

    public void setCanScroll(boolean isCanScroll) {
        this.isCanScroll = isCanScroll;
    }

    @Override
    public boolean onTouchEvent(MotionEvent ev) {
        if (isCanScroll)
            return super.onTouchEvent(ev);
        else
            return false;
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        if (isCanScroll)
            return super.onInterceptTouchEvent(ev);
        else
            return false;
    }

然后在setAdapter方法中修改

 @Override
    public void setAdapter(PagerAdapter adapter) {
        mAdapter = new LoopPagerAdapterWrapper(adapter);
        mAdapter.setBoundaryCaching(mBoundaryCaching);
        super.setAdapter(mAdapter);
        //fix blinking issue when item is scrolling from first to last,cause ViewPager instance item left current right at least,see more at setOffScreenLimit()
        setCurrentItem(mAdapter.getRealCount(), false);
        //个数小于2的时候不滚动
        if (mAdapter.getRealCount() < 2) {
            setCanScroll(false);
        }
    }

from android-convenientbanner.

saiwu-bigkoo avatar saiwu-bigkoo commented on June 14, 2024

我有提供stopTurning()方法出来的,而且你也可以判断数据只有一条就不startTurning就不会自己开启翻页。

from android-convenientbanner.

qq157755587 avatar qq157755587 commented on June 14, 2024

我知道stopTurning方法。我的意思是只有一条数据的时候,不仅仅是停止自动翻页,连手动翻页的操作都想禁止。

from android-convenientbanner.

saiwu-bigkoo avatar saiwu-bigkoo commented on June 14, 2024

hey,根据你的要求,我增加了一个接口,convenientBanner.setManualPageable(false);设置不能手动影响,请更新1.0.6版本吧

from android-convenientbanner.

qq157755587 avatar qq157755587 commented on June 14, 2024

Nice!

from android-convenientbanner.

qq157755587 avatar qq157755587 commented on June 14, 2024

manualPageable为false的时候,imageView的click事件会被吃掉吧。。。我是这样改的

if (!manualPageable && ev.getAction == MotionEvent.ACTION_MOVE) {
    return true;
}
return super.dispatchTouchEvent(ev);

不过这样有个缺点是 down-move-up 会被当成click事件。
最好是能禁止viewPager的无限循环。

from android-convenientbanner.

saiwu-bigkoo avatar saiwu-bigkoo commented on June 14, 2024

除了你这个方案,我也没有其他更好的idea了。

from android-convenientbanner.

qq157755587 avatar qq157755587 commented on June 14, 2024

adapter返回真实的数量,而不是count+2,并且onPageScrollStateChanged中不做任何事情。
不过这样改动就有点大了,可能和你最初的需求不同了。等我的PM发现上面那个缺点时我再自己fork一份改改吧:)

from android-convenientbanner.

saiwu-bigkoo avatar saiwu-bigkoo commented on June 14, 2024

楼上这样也不是最好的办法,甚至连点击事件都被覆盖了

from android-convenientbanner.

prience03 avatar prience03 commented on June 14, 2024

adapter.addHeader(convenientBanner) 把控件放到刷新的listview上,左右滑动的时候上下偏移就会有冲突。

from android-convenientbanner.

wangyao5018 avatar wangyao5018 commented on June 14, 2024

如果数据设置两条以上,
例如3条或者4条,上来就直接向左边滑动,控件会被清一下,
您的这个adapter处理我不太看得懂,
下面留一个gif,

http://wy.21bit.cn/test/sa.gif

from android-convenientbanner.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.