Closed shailesh242121 closed 8 years ago
Done with simple tric
If Any one want to use this
indicator.setViewPager(viewPager); indicator.onPageSelected(viewPager.getCurrentItem());
public void createIndicators(ViewPager viewPager,int selectedPosition) { removeAllViews(); if (viewPager.getAdapter() == null) { return; } int count = viewPager.getAdapter().getCount(); if (count <= 0) { return; }
for (int i = 0; i < count; i++) {
if(i==0 && selectedPosition==-1)
addIndicator(mIndicatorBackgroundResId, mAnimationOut);
else {
if(i==selectedPosition)
addIndicator(mIndicatorBackgroundResId, mAnimationOut);
else
addIndicator(mIndicatorUnselectedBackgroundResId, mAnimationIn);
}
}
}
You can view https://github.com/ongakuer/CircleIndicator/pull/28 pull request
If I have setup a view pager and added this lib. then if runtime there is one page added or one item is deleted. this doesn't update.
What i have done is when my pager is updated. I have call the method
createIndicators(View Pager);
this create a new list of pagerindicator it is OK. but the value/progress doesn't remain.
for this i have to call method setProgress(viewpager.getCurrentIndex());
This will move the the currenct page indicator to the right position.but in this situation there are two current page indicator on the screen first is on index one. and other one is on the right positoin.
There is need to add a observer with adapter or viewpager with this library.
hope you understand the issue.