Skip to content

Instantly share code, notes, and snippets.

@MotiurRahman
Created November 21, 2013 00:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MotiurRahman/7574176 to your computer and use it in GitHub Desktop.
Save MotiurRahman/7574176 to your computer and use it in GitHub Desktop.
Adding Menu to Action Bar in Tab Group apps
// 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