Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-17558] Android: Odd behaviour when using TabGroup + ActionBar

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionCannot Reproduce
Resolution Date2014-08-28T10:24:32.000+0000
Affected Version/sRelease 3.3.0
Fix Version/sn/a
ComponentsAndroid
LabelsTCSupport, android
ReporterJoseandro Luiz
AssigneeIngo Muschenetz
Created2014-07-15T16:26:34.000+0000
Updated2017-03-27T20:23:25.000+0000

Description

Problem Description

When creating an Android app with action bar followed by a tab group on Titanium 3.3.0.RC all works fine, but once try to display only text in the action bar, the app's tabs and action bar switch position. If we set title property and setDisplayShowTitleEnabled(true) set true in actionBar then we can reproduces this issue.

Steps to reproduce

1. Create a new mobile project (classic titanium) 2. Paste the test code into 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();

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 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 win3 = Titanium.UI.createWindow({
	title : 'Tab 3',
	backgroundColor : '#fff'
});
var tab3 = Titanium.UI.createTab({
	icon : 'KS_nav_ui.png',
	title : 'Tab 3',
	window : win3
});

//
// add tabs
//
tabGroup.addTab(tab1);
tabGroup.addTab(tab2);
tabGroup.addTab(tab3);

tabGroup.addEventListener("open", function(e) {
	var activity = tabGroup.getActivity();
	var actionBar = activity.actionBar;
	 actionBar.title = 'Title';
	
	 actionBar.setDisplayHomeAsUp( true );
	actionBar.setDisplayShowHomeEnabled(false);
	actionBar.setDisplayShowTitleEnabled(true);
	activity.onCreateOptionsMenu = function(e) {
		var item, menu;
		menu = e.menu;
		menu.clear();

		item = menu.add({
			title : "Tab1 Item",
			showAsAction : Ti.Android.SHOW_AS_ACTION_ALWAYS
		});

	};
});

tabGroup.addEventListener("focus", function(e) {
	tabGroup.getActivity().invalidateOptionsMenu();
});

// open tab group
tabGroup.open();

3. Run it in simulator

Extra information

Here's the original link to the question: http://developer.appcelerator.com/question/176150/odd-behaviour-when-using-tabgroup--actionbar

Attachments

FileDateSize
Screenshot_2014-08-28-15-37-43.png2014-08-28T10:23:35.000+000034622
Screen Shot 2014-07-15 at 5.16.50 PM.png2014-07-15T16:26:34.000+000046574

Comments

  1. Mauro Parra-Miranda 2014-07-30

    Hello! Can you please provide a testcase in the form of app.js? Thanks! Best Regards, Mauro
  2. Joseandro Luiz 2014-07-30

    It's in the link that I posted: https://gist.github.com/joseandro/99e202816e8928927fc2 Thanks
  3. jithinpv 2014-08-28

    Cannot reproduce in Titanium SDK version 3.4.0 master, 3.3.0.GA Shows a Runtime Error in Titanium SDK version 3.2.3.G.A Titanium Studio, build: 3.3.0.201407100905 Titanium Command-Line Interface CLI version 3.3.0, Android device : Motorola Moto G, Android version : 4.4.4
  4. Lee Morris 2017-03-27

    Closing ticket as I am unable to reproduce this issue with the following environment; Pixel (7.1) MacOS 10.11.6 (15G31) Studio 4.8.1.201612050850 Ti SDK 6.0.3 GA Appc NPM 4.2.8 Appc CLI 6.1.0 Ti CLI 5.0.11 Alloy 1.9.5 Arrow 1.10.1 Xcode 8.2 (8C38) Node v4.6.0 Java 1.7.0_80

JSON Source