| Platform | Since |
|---|---|
| Android | 1.5 |
The Titanium binding of an Android Menu
activity.onCreateOptionsMenu = function(e) { var menu = e.menu; var menuItem = menu.add({ title: "Item 1" }); menuItem.setIcon("item1.png"); menuItem.addEventListener("click", function(e) { Ti.API.debug("I was clicked"); }); };
var win = Ti.UI.createWindow({ fullscreen: true });</p> <p>var LOGIN = 1, LOGOUT = 2; var loggedIn = false; activity.onCreateOptionsMenu = function(e) { var menu = e.menu; var login = menu.add({ title: "Login", itemId: LOGIN }); login.setIcon("login.png"); login.addEventListener("click", function(e) { loggedIn = true; }); var logout = menu.add({ title: "Logout", itemId: LOGOUT }); logout.setIcon("logout.png"); logout.addEventListener("click", function(e) { loggedIn = false; }); };</p> <p>activity.onPrepareOptionsMenu = function(e) { var menu = e.menu; menu.findItem(LOGIN).setVisible(!loggedIn); menu.findItem(LOGOUT).setVisible(loggedIn); }; win.open();
| Name | Summary |
|---|---|
| add |
creates a |
| addEventListener |
Adds the specified callback as an event listener for the named event. |
| clear |
clear all items from the menu. You should release all references you have retained to |
| close |
close the menu if visible |
| findItem |
locate a |
| fireEvent |
Fires a synthesized event to any registered listeners. |
| getItem |
return the |
| getItems |
Gets the value of the items property. |
| hasVisibleItems |
query for any visible menu items |
| removeEventListener |
Removes the specified callback as an event listener for the named event. |
| removeGroup |
remove all |
| removeItem |
remove a specific |
| setGroupEnabled |
enable or disable a group of |
| setGroupVisible |
show or hide a group of |
| size |
number of |
| Name | Type | Summary |
|---|---|---|
| items | Array<Titanium.Android.MenuItem> |
array of |