I've implemented android.support.design.widget.TabLayout in my application. The tab contains dynamic data that comes from the API and also the dynamic content in a fragment. I'm calling the Tab wise APIs. But in my fragment all APIs calling the first fragment. So, it takes too much load to show the data. I want to call API particular tab wise. When the user will click to tab then API should be called.
I've set ArrayList size to offscreenPageLimit
like below
viewpager.offscreenPageLimit = mTaskStatusListResult.size
After researched I found https://stackoverflow.com/a/39455160/9635628
and set viewpager.offscreenPageLimit = 1
But still, the second tab's data are loading. i.e When a user enters the screen it loads first & second data when clicking the second tab the loads' third data.
I want to prevent that. Can you pls help. It'll be appreciated.