Titanium JIRA Archive
Appcelerator Community (AC)

[AC-1757] Unable to add item to the actionbar with tabGroup

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionCannot Reproduce
Resolution Date2014-01-06T00:09:44.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
LabelsAndroid, actionbar
ReporterRémi Burtin
AssigneeRitu Agrawal
Created2013-10-01T15:27:44.000+0000
Updated2016-03-08T07:40:38.000+0000

Description

Problem

Since 3.1.2.GA i'm unable to add item to the actionbar on a tabGroup. I've joined code to reproduce. This code work with 3.1.1.GA.

Test case

var self = Ti.UI.createTabGroup({
	fullscreen : true,
	title : 'Action Bar'
});

//create app tabs

var win1 = Ti.UI.createWindow({
	title : 'win1'
});


var tab1 = Ti.UI.createTab({
	title : 'tab1',
	window : win1
});

var win2 = Ti.UI.createWindow({
	title : 'win1'
});

var tab2 = Ti.UI.createTab({
	title : 'tab2',
	window : win2
});

self.addTab(tab1);
self.addTab(tab2);

self.open();

tab1.window.addEventListener('focus', function(){
	tab1.window.activity.onCreateOptionsMenu = function(e) {
		var menu = e.menu;
		var aboutMenuItem = menu.add({
			title : "About",
			showAsAction : Ti.Android.SHOW_AS_ACTION_IF_ROOM
		});
		aboutMenuItem.addEventListener("click", function(e) {
			alert("About Item Clicked!");
		});
		var settingsMenuItem = menu.add({
			title : "Settings",
			showAsAction : Ti.Android.SHOW_AS_ACTION_IF_ROOM
		});
		settingsMenuItem.addEventListener("click", function(e) {
			alert("Settings Item Clicked!");
		});
	};
});

<?xml version="1.0" encoding="UTF-8"?>
<ti:app xmlns:ti="http://ti.appcelerator.org">
    <id>com.test.actionbar</id>
    <name>ActionBarSampleTi</name>
    <version>1.0</version>
    <publisher>_</publisher>
    <url>http://</url>
    <description>not specified</description>
    <copyright>_</copyright>
    <icon>appicon.png</icon>
    <persistent-wifi>false</persistent-wifi>
    <prerendered-icon>false</prerendered-icon>
    <statusbar-style>default</statusbar-style>
    <statusbar-hidden>false</statusbar-hidden>
    <fullscreen>false</fullscreen>
    <navbar-hidden>false</navbar-hidden>
    <analytics>false</analytics>
    <guid>99a04c4e-689f-4a4c-9870-a0843d7f21c0</guid>
    <property name="ti.ui.defaultunit" type="string">system</property>
    <iphone>
        <orientations device="iphone">
            <orientation>Ti.UI.PORTRAIT</orientation>
        </orientations>
        <orientations device="ipad">
            <orientation>Ti.UI.PORTRAIT</orientation>
            <orientation>Ti.UI.UPSIDE_PORTRAIT</orientation>
            <orientation>Ti.UI.LANDSCAPE_LEFT</orientation>
            <orientation>Ti.UI.LANDSCAPE_RIGHT</orientation>
        </orientations>
    </iphone>
    <android xmlns:android="http://schemas.android.com/apk/res/android">
        <tool-api-level>16</tool-api-level>
        <manifest>
            <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="11"/>
        </manifest>
    </android>
    <modules/>
    <deployment-targets>
        <target device="tizen">false</target>
        <target device="blackberry">false</target>
        <target device="android">true</target>
        <target device="ipad">false</target>
        <target device="iphone">false</target>
        <target device="mobileweb">false</target>
    </deployment-targets>
    <sdk-version>3.1.3.GA</sdk-version>
    <property name="ti.deploytype">test</property>
</ti:app>

Attachments

FileDateSize
app.js2013-10-01T15:27:44.000+0000954
Screenshot 2013-12-24 11.48.59.png2013-12-24T07:09:53.000+000028204
tiapp.xml2013-10-01T15:27:44.000+00001900

Comments

  1. Mostafizur Rahman 2013-10-27

    Hello Rémi Burtin, PLease check my following code for Actionbar in TabGroup.

    My test Environment follows:

    Ti SDK 3.1.3.GA Android SDK 4.0.0

    Test Code

       var self = Ti.UI.createTabGroup({
       	fullscreen : true,
       	title : 'Action Bar'
       });
        
       var win1 = Ti.UI.createWindow({
       	title : 'win1'
       });
       
       var tab1 = Ti.UI.createTab({
       	title : 'tab1',
       	window : win1
       });
       
       var win2 = Ti.UI.createWindow({
       	title : 'win1'
       });
       
       var tab2 = Ti.UI.createTab({
       	title : 'tab2',
       	window : win2
       });
       
       self.addTab(tab1);
       self.addTab(tab2);
       
       self.open();
       
       self.addEventListener('open', function(e) {
       	var activity = self.getActivity();
       
       	activity.onCreateOptionsMenu = function(e) {
       		var menu = e.menu;
       
       		// Menu Item 1
       		var menuItem1 = menu.add({
       			title : "Item 1",
       			icon : "images/action_about.png",
       			showAsAction : Ti.Android.SHOW_AS_ACTION_ALWAYS
       		});
       		menuItem1.addEventListener("click", function(e) {
       			alert("I was clicked 1");
       		});
       
       		// Menu Item 2
       		var menuItem2 = menu.add({
       			title : "Item 2",
       			icon : "images/action_settings.png",
       			showAsAction : Ti.Android.SHOW_AS_ACTION_ALWAYS
       		});
       		menuItem2.addEventListener("click", function(e) {
       			alert("I was clicked 2");
       		});
       	};
       });
       
       
       <?xml version="1.0" encoding="UTF-8"?>
       <ti:app xmlns:ti="http://ti.appcelerator.org">
           <id>com.stendapps.teststatusbar</id>
           <name>QnA</name>
           <version>1.0</version>
           <publisher>stefano</publisher>
           <url>http://</url>
           <description>not specified</description>
           <copyright>2013 by stefano</copyright>
           <icon>appicon.png</icon>
           <persistent-wifi>false</persistent-wifi>
           <prerendered-icon>false</prerendered-icon>
           <statusbar-style>default</statusbar-style>
           <statusbar-hidden>false</statusbar-hidden>
           <fullscreen>true</fullscreen>
           <navbar-hidden>false</navbar-hidden>
           <analytics>true</analytics>
           <guid>056b02f9-512f-4a40-b1b6-fe7412fb2590</guid>
           <property name="ti.ui.defaultunit" type="string">system</property>
           <property name="ti.facebook.appid">410842299029388</property>
           <iphone>
               <orientations device="iphone">
                   <orientation>Ti.UI.PORTRAIT</orientation>
               </orientations>
               <orientations device="ipad">
                   <orientation>Ti.UI.PORTRAIT</orientation>
                   <orientation>Ti.UI.UPSIDE_PORTRAIT</orientation>
                   <orientation>Ti.UI.LANDSCAPE_LEFT</orientation>
                   <orientation>Ti.UI.LANDSCAPE_RIGHT</orientation>
               </orientations>
           </iphone>
           <android xmlns:android="http://schemas.android.com/apk/res/android">
              
               <manifest android:installLocation="preferExternal">
               	<supports-screens android:anyDensity="false"/>
               	<uses-sdk android:maxSdkVersion="17" android:minSdkVersion="8" android:targetSdkVersion="14"/>
               	<application>
                       <activity android:alwaysRetainTaskState="true"
                           android:configChanges="keyboardHidden|orientation"
                           android:label="Test "
                           android:name=".QnaActivity" android:theme="@android:style/Theme.Holo.Light">
                           <intent-filter>
                               <action android:name="android.intent.action.MAIN"/>
                               <category android:name="android.intent.category.LAUNCHER"/>
                           </intent-filter>
                            
                       </activity> 
                   </application>
                    
               </manifest>
           </android>
           <mobileweb>
               <precache/>
               <splash>
                   <enabled>true</enabled>
                   <inline-css-images>true</inline-css-images>
               </splash>
               <theme>default</theme>
           </mobileweb>
           <modules>
               <module platform="android">ti.map</module>
           </modules>
           <deployment-targets>
               <target device="android">true</target>
               <target device="blackberry">false</target>
               <target device="ipad">true</target>
               <target device="iphone">true</target>
               <target device="mobileweb">true</target>
               <target device="tizen">false</target>
           </deployment-targets>
           <sdk-version>3.1.3.GA</sdk-version>
           <property name="ti.deploytype">development</property>
       </ti:app>
       
       
    Thanks
  2. Ritu Agrawal 2014-01-06

    Closing this ticket as we have not been able to reproduce this issue. Please let us know if the issue persists with 3.2.0 GA release and we would be happy to reopen the ticket and investigate it further.

JSON Source