Reputation: 21
I am using ActionBarSherlock on Android 4.0.3, so it might use the native ActionBar.
When I launch my application everything works fine. However, when I go to the Homescreen and wait until its killed (or simply change the system font, then it happens imediately) and then switch by the "last used"-dialog again to the app everything reloads smoothly, except the Actionbar has now empty tabs.
So the tabs are there, but empty (and do not work). The strange thing is that even in the Application object onCreate is called (as in the TabParentActivity, see code below), so theoretically the Application should have been completely restarted (and not just partially like onResume...).
When I then kill my app (via the task manager) and reopen it the problem has gone.
How I add the Actionbar in my TabParentActivity:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tab_parent);
//Global initialization
...
ActionBar ab = getSupportActionBar();
// set defaults for logo & home up
ab.setDisplayShowHomeEnabled(true);
ab.setDisplayShowTitleEnabled(false);
ab.setDisplayHomeAsUpEnabled(false);
ab.setDisplayUseLogoEnabled(true);
ab.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
...
for(StolScreen s: screensInTabs){
Tab t = mAb.newTab().setText(s.displayName);
t.setTabListener(new NormalTabListener(this.mActivity, s));
mAb.addTab(t);
}
}
How it looks like: All ok Now tabs empty
Upvotes: 1
Views: 949
Reputation: 21
I was now able to solve it by myself. The reason is really crazy: In the above code I set the label of a tab in the loop with the s.displayName. s is belonging to an Enum called StolScreen.
In there the displayName is initialized via a call in Tools (initialized before), which retrieves the display name from an xml file. What was now actually happening when I was returning to the activity (and only then), was that StolScreen was loaded (in an Enum the fields are loaded like static members) BEFORE Tools was initialized.
So just an empty String was put on the tabs :D. Anyway, thx 4 help ;)
Upvotes: 1