-2

I implemented a swipe tab in a fragment. This fragment has two tabs, tab1 and tab2. when i click on tab2, a new activity will load. however, when i click on the back button, it directs to the fragment but not the tab i selected previously. it should display tab2 not tab1 contents. how can i do that?

user5083862
  • 67
  • 1
  • 6

1 Answers1

0

You need to remember on which tab you were onStop(), for example using SharedPreferences, or startActivityWithResult when you start your activity. Then when you come back, check onStart() and retrieve from the SharedPreferenes, or 'onResult' and move the tab to the good tab.

xiaomi
  • 6,553
  • 3
  • 29
  • 34