I have extended the ViewPager class and implemented onPageChangeListener. I use this ViewPager in conjunction with a CirclePageIndicator inside a SherlockFragment. The ViewPager
When you use PageIndicator in conjunction with the Viewpager then the onPageChangeListener of the ViewPager is not called. I don't know the reason for this but this happened when I was using both. May be cause the page indicator consumes the page change event. Instead you should set a page change listener to the PageIndicator and it will be called when the page changes. Here is how you can do this:
indicator.setOnPageChangeListener(new OnPageChangeListener() {
@Override
public void onPageSelected (int page)
{
//page changed
}
@Override
public void onPageScrolled (int arg0, float arg1, int arg2)
{
}
@Override
public void onPageScrollStateChanged (int arg0)
{
}
});
I hope this will help. Feel free to discuss.
setOnPageChangeListener
is deprecated.
use addOnPageChangeListener
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
}
@Override
public void onPageScrollStateChanged(int state) {
}
});