M
M
mitaichik2017-06-18 19:00:55
Android
mitaichik, 2017-06-18 19:00:55

How to force ViewPager not to create adjacent fragments?

Hello! I have 2 tabs in my ViewPager. As you know, ViewPager immediately creates fragments for neighboring tabs.
In one fragment (tab) that users visit very rarely, in onCreate I have a request to the server. And I would not like to send it until the user has switched to it.
How to force the ViewPager not to create a neighboring fragment immediately, or how to track that the fragment has become active (it’s from the enemy, in the ViewPager it’s clear how)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denis Zagaevsky, 2017-06-18
@zagayevskiy

Forbid xs as, and the visibility of user visible hint. Details here - https://stackoverflow.com/a/12523627

D
davidnum95, 2017-06-20
@davidnum95

If you decide the question directly, then: And if it's wise, then you need to check which tab is currently active, and load the data that is necessary for the current tab. You can track it by forwarding the tab change interface from ViewPager to fragments

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question