1

I would like to know why when screen orientation is changed current tab changes back to default one in TabHost?

I understand that the Activity is destroyed and created again, but why the state of TabHost isn't saved? Per example, text of an EditText is saved and restored, why is it different for current tab? Do I have to do it myself?

Thanks

Kobe-Wan Kenobi
  • 3,694
  • 2
  • 40
  • 67

1 Answers1

0

You are responsible for managing your own tabs ( fragment transactions). So it follows that if you want a particular tab to be selected then you have to save state information prior to the configuration change.

This may help (especially if you follow the link in the answer):

How can I prevent the current tab view from being lost when rotating the screen?

By default, EditText saves its own instance. See Yalla T's answer here:

How to retain EditText data on orientation change?

Community
  • 1
  • 1
IanB
  • 3,489
  • 1
  • 20
  • 24
  • Ok, thanks for your answer and for confirmation that you have to handle it yourself. Can you tell me why is this view different than edittext that handles the orientation change itself? – Kobe-Wan Kenobi Jun 25 '14 at 08:51
  • 1
    Thanks again, but one more thought about that, isn't it more probable that its text is saved, rather than the whole instance is saved? Because a totally different look of edittext can be specified for the other orientation, in that way all the attributes would have to be changed, so it could respect the new appearance? – Kobe-Wan Kenobi Jun 25 '14 at 09:43
  • You could be correct - I haven't used EditText in any of my apps yet. – IanB Jun 25 '14 at 14:38