Just wanted to share how to set up menus in Android on the last SDK's 1.5.0 and onwards.
Introducing menucreation on the activity from 1.5.0 onwards, it can sometimes be unclear how to make it work. Especially if you run your applicaton in the app.js file.
There are two important things to do. First, open a "heavy" window using either navBarHidden, fullScreen or the modal parameter to a value when creating the window. This forces the window to get its own Activity.
Codesnippet from my app.js:
var appWin = Titanium.UI.createWindow({ navBarHidden: false }); var gam = null; var ram = null; var connectEvents = function() { Titanium.API.info("wireing click handlers"); gam.addEventListener('click', function() { Showall(); }); ram.addEventListener('click', function() { RemoveAll(); }); } appWin.activity.onCreateOptionsMenu = function(e) { Titanium.API.info("creating the menus"); var menu = e.menu; gam = menu.add({title : 'Show All'}); ram = menu.add({title : 'Remove All'}); //connect the events connectEvents(); }Pretty much as documented, but the important part missing is to add the params which does create the needed activity object. And then the syntax to use the newly created activity for your window.
It took me a long time to figure this out, and I had to read about menus in the Android SDKs for it.
I was struggling with this for days, hopefully it will help someone!
Harald
1 Answer
Accepted Answer
Cool, thanks for the tip!
Your Answer
Think you can help? Login to answer this question!