0

I have 4 fragments in my viewpager and each fragment is shown in each tab and I have 4 tabs. When I click my third tab or swipe to third tab, I find that, the fourth fragment's onresume method is executed, everytime I swipe through fragments, I see that the next page's on resume is executed.

I only want to execute selected fragment's on resume, not the fragment next to it, I searched a lot, but I cannot find a way to do it, is there a way to do it ? thank you

Psypher
  • 10,717
  • 12
  • 59
  • 83
user3767986
  • 25
  • 1
  • 6

1 Answers1

0

You cannot do that, the viewpager requires at least one fragment to the left and one to the right. I suggest you move the onResume() logic to a separate method and call it when the fragment becomes visible.

Try this : How to determine when Fragment becomes visible in ViewPager

Community
  • 1
  • 1