var activity = win.getActivity();
// Re-create Menu
if(activity){
activity.onCreateOptionsMenu = function(e){
var item, menu;
menu = e.menu;
menu.clear();
var menuItem = menu.add({
visible: true,
title: 'title1',
showAsAction : Ti.Android.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW
});
var menuItem2 = menu.add({
title : "title2",
visible: true,
showAsAction : Ti.Android.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW
});
menuItem.addEventListener('click', function(e){
console.log("aaaaa");
});
activity.invalidateOptionsMenu();
};
}
{noformat}
[ERROR] : TiExceptionHandler: (main) [158,158] menuItem.addEventListener('click', function(e){
[ERROR] : TiExceptionHandler: ^
[ERROR] : TiExceptionHandler: TypeError: menuItem.addEventListener is not a function
[ERROR] : TiExceptionHandler: at Activity.activity.onCreateOptionsMenu (eval at Module._compile (/app.js:728:13),
:404:14)
[ERROR] : V8Exception: Exception occurred at undefined:404: Uncaught TypeError: menuItem.addEventListener is not a function
{noformat}
You can close this ticket, it's not a bug, I solve it, mixed problems in my code.
@Lorenzo can you please give a description about your code? I too cannot call _addEventListener_ on MenuItems. How did you solve it?