Keep the last selected tab after moving to page 2 android

  • Replies:3
Chinmaya Kumar
  • 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

Reply
Cat Sorcerer
  • 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?

Reply
Ashish Tripathi
  • Forum posts: 211

Feb 4, 2013, 12:50:41 PM via Website

brief your problem.

Reply
Henrik Lindqvist
  • Forum posts: 25

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

You need to save the currently selected tab yourself:

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

Reply