Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-23271] Android: ActionBar not available for TabGroup

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionDuplicate
Resolution Date2019-01-11T01:27:01.000+0000
Affected Version/sRelease 5.2.0, Release 5.2.2
Fix Version/sn/a
ComponentsAndroid
Labelsn/a
ReporterJebun Naher
AssigneeYordan Banev
Created2016-04-25T11:38:05.000+0000
Updated2019-01-11T01:27:05.000+0000

Description

I tried to hide the action bar by following the doc here: http://docs.appcelerator.com/platform/latest/#%21/guide/Android_Action_Bar-section-36735509_AndroidActionBar-HidingtheActionBar As the doc says: *To automatically hide the action bar when opening a window or tab group, you need to modify the theme to hide the action bar.* But modifying the theme when opening a tabgroup results following error: [ERROR] : TabGroupProxy: (main) [315,315] ActionBar not available for TabGroup *Reproduction:* 1. Create a classic app and replace app.js with the sample code 2. Add custom theme and modify tiapp.xml 3. Run the app Expected: No action bar should be visible Actual: [ERROR] : TabGroupProxy: (main) [315,315] ActionBar not available for TabGroup *Test Case:* app.js
// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('#000');

// create tab group
var tabGroup = Titanium.UI.createTabGroup();
//
// create base UI tab and root window
//
var win1 = Titanium.UI.createWindow({  
    title:'Tab 1',
    backgroundColor:'#fff'
});
var tab1 = Titanium.UI.createTab({  
    icon:'KS_nav_views.png',
    title:'Tab 1',
    window:win1
});

var label1 = Titanium.UI.createLabel({
	color:'#999',
	text:'I am Window 1',
	font:{fontSize:20,fontFamily:'Helvetica Neue'},
	textAlign:'center',
	width:'auto'
});

win1.add(label1);

//
// create controls tab and root window
//
var win2 = Titanium.UI.createWindow({  
    title:'Tab 2',
    backgroundColor:'#fff'
});
var tab2 = Titanium.UI.createTab({  
    icon:'KS_nav_ui.png',
    title:'Tab 2',
    window:win2
});

var label2 = Titanium.UI.createLabel({
	color:'#999',
	text:'I am Window 2',
	font:{fontSize:20,fontFamily:'Helvetica Neue'},
	textAlign:'center',
	width:'auto'
});

win2.add(label2);
tabGroup.addTab(tab1);  
tabGroup.addTab(tab2);  
// open tab group
tabGroup.open();
*tiapp.xml*
<android xmlns:android="http://schemas.android.com/apk/res/android">
<manifest>
<application android:theme="@style/Theme.NoActionBar"/>
</manifest>
</android>
*custom_theme.xml*
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.NoActionBar" parent="@style/Theme.AppCompat">
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
<!-- AppCompat Compatibility -->
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
</resources>

Comments

  1. Ashraf Abu 2016-08-26

    Adding information here, by setting the theme to use NoActionBar, you remove the actionbar from the activity itself. This causes this error [https://github.com/appcelerator/titanium_mobile/blob/2ae0b782cb24bcae624c5c909ee108e0812eb7dd/android/modules/ui/src/java/ti/modules/titanium/ui/TabGroupProxy.java#L362-L367] which is mentioned in the ticket.
  2. Ashraf Abu 2016-08-26

    Seems like in this case, the TabGroup depends on ActionBar being available (even if it is not needed). Hence, when ActionBar is removed by setting it in the Theme, TabGroup fails.
  3. Gary Mathews 2016-09-03

    So it seems an ActionBar is required in order for TabGroup to function. However, there is a workaround you could use to hide it:
       tabGroup.addEventListener('open', function() {
           tabGroup.activity.actionBar.hide();
       });
       
  4. Yordan Banev 2018-10-04

JSON Source