Giter VIP home page Giter VIP logo

Comments (5)

eeVoskos avatar eeVoskos commented on August 16, 2024

I had the same problem when updated from v1.13 to v1.14. With a bit of search in the source code, I saw that CircleIndicator now implements OnPageChangeListener.

This solution worked for me:

mPager.setAdapter(adapter);
mIndicator.setViewPager(mPager);
mPager.addOnPageChangeListener(mIndicator);

I think the above behaviour should be reflected in the sample app.

from circleindicator.

drac94 avatar drac94 commented on August 16, 2024

Thanks @eeVoskos, sadly that's not working for me, my code look like this

mPager = (ViewPager) findViewById(R.id.pager);
CircleIndicator defaultIndicator = (CircleIndicator) findViewById(R.id.indicator_default);
mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
mPager.setAdapter(mPagerAdapter);
mPager.setCurrentItem(position);
defaultIndicator.setViewPager(mPager);
mPager.addOnPageChangeListener(defaultIndicator);

But doesn't matter which position the ViewPager starts, the first indicator is always active, I'm doing something wrong?

from circleindicator.

drac94 avatar drac94 commented on August 16, 2024

nvm, I switched this two lines and now it's working like a charm

mPager.setCurrentItem(position);
defaultIndicator.setViewPager(mPager);

from circleindicator.

eeVoskos avatar eeVoskos commented on August 16, 2024

Try calling mPager.setCurrentItem(position) last, after initializing the ViewPager and the CircleIndicator:

mPager = (ViewPager) findViewById(R.id.pager);
CircleIndicator defaultIndicator = (CircleIndicator) findViewById(R.id.indicator_default);
mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
mPager.setAdapter(mPagerAdapter);
defaultIndicator.setViewPager(mPager);
mPager.addOnPageChangeListener(defaultIndicator);
mPager.setCurrentItem(position);

from circleindicator.

ongakuer avatar ongakuer commented on August 16, 2024

@eeVoskos is right.

from circleindicator.

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.