Skip to content

Instantly share code, notes, and snippets.

@manumaticx
Last active December 18, 2015 16:59
Show Gist options
  • Save manumaticx/5815331 to your computer and use it in GitHub Desktop.
Save manumaticx/5815331 to your computer and use it in GitHub Desktop.
tab-dependend OptionsMenu
// create a tab-dependend OptionsMenu
function createOptionsMenu(e){
var menu = e.menu;
menu.clear();
// tab-dependend part
switch(self.activeTab){
case tab1:
// all menuItems for Tab 1
var menuItem_settings = menu.add({
title: L('settings'),
showAsAction : Ti.Android.SHOW_AS_ACTION_NEVER // this goes into overflow menu
});
menuItem_settings.addEventListener('click', function(){
alert('clicked: Settings');
});
// now, let's create an action for this Tab
// (it will appear in the usual Menu on older APIs)
var menuItem_about = menu.add({
title: L('about'),
icon: 'images/action_about.png',
showAsAction : Ti.Android.SHOW_AS_ACTION_ALWAYS // this is shown as Action
});
menuItem_about.addEventListener('click', function(){
alert('clicked: About');
});
break;
case tab2:
// all menuItems for Tab 2
var menuItem_settings = menu.add({
title: L('refresh'),
showAsAction : Ti.Android.SHOW_AS_ACTION_NEVER // this goes into overflow menu
});
menuItem_settings.addEventListener('click', function(){
alert('clicked: Refresh');
});
break;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment