Reputation: 23
I have designed material design sliding tabs in android. I have added 3 tabs and want to change the UI at runtime from main activity but only 2 fragments has been instantiated and accessed except the 3rd. how to get the 3rd fragment to be instantiated and accessed?
Upvotes: 0
Views: 138
Reputation: 8734
By default the offscreenPageLimit
for the ViewPager
is 1
. so, the ViewPager
loads and extra one page from left and one page from right (total 3 pages).
You can change that by calling ViewPager.setOffscreenPageLimit(2);
this will load a 2
pages from each side (total 5 pages).
Upvotes: 3