viezel / NappDrawer

A side drawer navigation container view controller for Appcelerator Titanium.
MIT License
247 stars 128 forks source link

OptionsMenu #151

Open amrdesign opened 9 years ago

amrdesign commented 9 years ago

hello

any one know how use this code with drawer

var win = Ti.UI.createWindow({ fullscreen: true }); var LOGIN = 1, LOGOUT = 2; var loggedIn = false;

var activity = win.activity;

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; // In Android 3.0 and above we need to call invalidateOptionsMenu() for menu changes at runtime win.activity.invalidateOptionsMenu(); }); var logout = menu.add({ title: "Logout", itemId: LOGOUT }); logout.setIcon("logout.png"); logout.addEventListener("click", function(e) { loggedIn = false; // In Android 3.0 and above we need to call invalidateOptionsMenu() for menu changes at runtime win.activity.invalidateOptionsMenu(); }); };

activity.onPrepareOptionsMenu = function(e) { var menu = e.menu; menu.findItem(LOGIN).setVisible(!loggedIn); menu.findItem(LOGOUT).setVisible(loggedIn); }; win.open();