Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The first circle is always active #21

Closed
drac94 opened this issue Jun 23, 2015 · 5 comments
Closed

The first circle is always active #21

drac94 opened this issue Jun 23, 2015 · 5 comments

Comments

@drac94
Copy link

drac94 commented Jun 23, 2015

Hi, first of all, great work.
Is there any way to "deactivate" the first circle?, when I set the setCurrentItem in the adapter, the circle on that position is well activated but also the first one.

Regards.

@eeVoskos
Copy link

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.

@drac94
Copy link
Author

drac94 commented Jun 24, 2015

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?

@drac94
Copy link
Author

drac94 commented Jun 24, 2015

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

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

@eeVoskos
Copy link

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);

@ongakuer
Copy link
Owner

@eeVoskos is right.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants