Created
November 21, 2013 00:59
-
-
Save MotiurRahman/7574176 to your computer and use it in GitHub Desktop.
Adding Menu to Action Bar in Tab Group apps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Hi, Here create a tabGroup and add a action bar menu named Action Menu. | |
var tabGroup = Titanium.UI.createTabGroup(); | |
var win1 = Ti.UI.createWindow({ | |
backgroundColor : '#000' | |
}); | |
var win2 = Ti.UI.createWindow({ | |
backgroundColor : '#000' | |
}); | |
var tab1 = Titanium.UI.createTab({ | |
icon : 'KS_nav_views.png', | |
title : 'Student', | |
window : win1, | |
}); | |
win1.containingTab = tab1; | |
tabGroup.addTab(tab1); | |
var tab2 = Titanium.UI.createTab({ | |
icon : 'KS_nav_views.png', | |
title : 'Teacher', | |
window : win2, | |
}); | |
win2.containingTab = tab2; | |
tabGroup.addTab(tab2); | |
if (Ti.Platform.name === "android") { | |
tabGroup.addEventListener("open", function(e) { | |
var activity = tabGroup.getActivity(); | |
activity.onCreateOptionsMenu = function(e) { | |
var menuItem = e.menu.add({ | |
title : "Action Menu", | |
showAsAction : Ti.Android.SHOW_AS_ACTION_ALWAYS, | |
icon : "icon.png" | |
}); | |
menuItem.addEventListener("click", function(e) { | |
alert('Hi I Am Menu of Action Bar'); | |
}); | |
}, activity.invalidateOptionsMenu(); | |
}); | |
} | |
tabGroup.open(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment