Reputation: 179
I have tabhost with 4 tabs. If I (for example) open tab #3, start a simple alert dialog, and then rotate the phone a few times, it loses focus on which tab was open before, so when I press back, tab #1 shows up instead of tab #3.
I would be very grateful for a solution or any hints to solve this problem.
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
saveState();
}
protected void onPause() {
super.onPause();
saveState();
}
protected void onResume() {
super.onResume();
getTabHost().setCurrentTab(currentTab);
}
private void saveState(){
currentTab=getTabHost().getCurrentTab();
}
Upvotes: 1
Views: 2220
Reputation: 4943
Did you try save state of TabHost? If not - check Reto Meier answer in this discussion.
You can save current position of TabHost using getCurrentTab at onSaveInstanceState, and restore it at onRestoreInstanceState using setCurrentTab.
Upvotes: 4