Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot setCurrentItem(0) on CirclePageIndicator

If you have this code in Activity onCreate():

mViewPager = new ViewPager(this, null);
mPagerAdapter = new PagerAdapter(this);
mViewPager.setAdapter(mPagerAdapter);
mCirclePageIndicator.setViewPager(mViewPager);
mCirclePageIndicator.setOnPageChangeListener(onPageChangeListener);

Then launch an AsyncTask and want to change the current page in it's onPostExecute() with the page 0, then it won't work. It works with any other page != 0, but with 0 it just retains the current position.

mCirclePageIndicator.setCurrentItem(0);

If anybody comes up with an idea, feel free to share. Thanks !

like image 334
Bogdan Zurac Avatar asked Jan 24 '26 03:01

Bogdan Zurac


1 Answers

Workaround:

First set another page as the current page, then set to page 0. Yes, I know, it's retarded, but I still haven't found an explication as to why it isn't working in the first place. I've tried posting it in a Handler, even with a delay, but nothing. Nada.

mCirclePageIndicator.setCurrentItem(1);
mCirclePageIndicator.setCurrentItem(0);
like image 123
Bogdan Zurac Avatar answered Jan 26 '26 17:01

Bogdan Zurac