I have a ViewPager with the 10 images comes through webservices(JSON), At first ViewPager work smoothly (fine).
but When back from the activity and reopen it
Reason of the problem the Pager can be refreshed during some measurement and in this case will refresh count of your adapter, if this count will not equals with saved count you will see the error. So my solution looks:
public abstract class ViewPagerCursorAdapter extends PagerAdapter {
private int mCount;
public ViewPagerCursorAdapter(Context ctx, Cursor cursor, int resource) {
super();
...
mCount = cursor.getCount();
...
}
@Override
public int getCount() {
return mCount;
}
public Cursor swapCursor(Cursor newCursor) {
...
mCount = newCursor.getCount();
notifyDataSetChanged();
}
}
Good luck.