I am trying to add an Android options menu to the default tabbed-app template, but I can't get it to work. The options menu is not shown on press of the menu icon.
var activity = Ti.Android.currentActivity; Ti.API.info("Android Activity Menu "+activity); activity.onCreateOptionsMenu = function(e){ Ti.API.info("menu"); var menu = e.menu; var menuitem = menu.add({title: "Item1"}); menuitem.addEventListener("click", function(){ alert("clicked menu item"); }); };I've tried adding this to the commonJS window file and to the tabgroup, even in the app.js file but it's not being shown. Also I've tried 1.8.0.1 and 1.8.1 SDKs.
Are there any specials to consider when trying to use this with commonjs conventions?
This is the console output that's generated on click:
W/KeyCharacterMap( 331): No keyboard for id 0 W/KeyCharacterMap( 331): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
1 Answer
OK I got it working now. Docs are really not clear.
I grabbed the activ windows and now it works:
var activity = win.activity; activity.onCreateOptionsMenu = function(e) {
Your Answer
Think you can help? Login to answer this question!