I'm using ViewPager in my app and define it in the main Activity. Inside onCreate
method I load some number of pages from SharedPreferences and then pass it to PagerAdapter:
@Override
public int getCount() {
return numberOfPages;
}
The problem is that if I would change this number in Preferences (or another Activity) to some other less then page index I viewed before, my app crashes because this index is out of bounds when I return to the activity with this ViewPager. It can be fixed simply by changing active ViewPager's page. Is there any way to do it?
0
inonPause
method and there is no crashes. Thanks. – Windowsill