Keep the last selected tab after moving to page 2 android

  • Replies:3
  • OpenNot stickiedUnanswered

Nov 22, 2012 6:21:49 AM

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

Mar 7, 2013 7:55:03 PM

You need to save the currently selected tab yourself:

@Override
protected void onSaveInstanceState (Bundle state) {
super.onSaveInstanceState(state);
state.putInt(POSITION, getCurrentItem());
}