Sundari Narayanan
Sundari Narayanan

Reputation: 23

Material design sliding tabs not accessing more than two fragments

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

Answers (2)

JafarKhQ
JafarKhQ

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

WISHY
WISHY

Reputation: 11999

Refer this

Implement Sliding Tab Layout

Upvotes: -1

Related Questions