I believe your issue is that the window is not fully created by the time your are trying to set the title.
I act upon the focus event of the tabgroup (which actually bubbles up from the tab) and I assign the ActionBar title based on the tab.
For ActionBars within TabGroups, I do the the following:
View:
<Alloy>
<TabGroup id="tabGroup1">
<Tab id="tab1">
<Window id="window1"></Window>
</Tab>
<Tab id="tab2">
<Window id='window2'></Window>
</Tab>
</TabGroup>
</Alloy>
Controller:
/**
* Listen to focus on the tabgroup and pass the title to the ActionBar
*/
$.tabGroup1.addEventListener('focus', function(){
if( OS_ANDROID && Ti.Platform.Android.API_LEVEL >= 11 ) {
var tabGroup = $.tabGroup1,
activity = tabGroup.getActivity(),
actionBar;
if(!activity){
Ti.API.error('No activity created for mainTabGroup');
} else {
actionBar = activity.actionBar;
if(!actionBar){
Ti.API.error('No ActionBar created for mainTabGroup activity');
} else {
actionBar.setTitle(tabGroup.activeTab.title);
}
}
}
});
$.mainTabGroup.open();
By using the focus event of the TabGroup your are ensuring the components are available when you need to modify them.