Keep the last selected tab after moving to page 2 android

  • Replies:3
  • OpenNot stickiedUnanswered
  • Forum posts: 1

Nov 22, 2012 6:21:49 AM via Website

i have two tabs tab1 and tab2 on my homescreen by default tab1 is selected ,I select tab2 and go to other screen when i return i found tab1 is selected problem-i want the tab which was selected previously should retain selected when go to another screen
  • Forum posts: 13

Dec 3, 2012 11:57:34 PM via Website

Can you explain a bit more? Do you mean switch from one view to another then go back?
  • Forum posts: 25

Mar 7, 2013 7:55:03 PM via Website

You need to save the currently selected tab yourself:

protected void onSaveInstanceState (Bundle state) {
state.putInt(POSITION, getCurrentItem());