Created
April 22, 2013 12:46
-
-
Save DirleiDionisio/5434633 to your computer and use it in GitHub Desktop.
Using Android native ActionBar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* tool-api-level and targetSdkVersion must be 11 or higher on TiApp.xml. Ex: | |
<android xmlns:android="http://schemas.android.com/apk/res/android"> | |
<tool-api-level>11</tool-api-level> | |
<manifest> | |
<uses-sdk android:targetSdkVersion="11"/> | |
</manifest> | |
</android> | |
more info: http://docs.appcelerator.com/titanium/latest/#!/guide/Android_Action_Bar */ | |
var w = Ti.UI.createWindow({ | |
title: 'Título da janela', | |
fullscreen: false, // we must define this property in order to create a heavyweight window | |
exitOnClose: true | |
}); | |
w.activity.onCreateOptionsMenu = function(e) { | |
var menuItem = e.menu.add({ | |
title: "Menu1", | |
showAsAction: Ti.Android.SHOW_AS_ACTION_ALWAYS | |
}); | |
menuItem.addEventListener("click", function(e) { | |
alert("Menu1 clicked"); | |
}); | |
menuItem = e.menu.add({ | |
title: "Menu2", | |
showAsAction: Ti.Android.SHOW_AS_ACTION_ALWAYS | |
}); | |
menuItem.addEventListener("click", function(e) { | |
alert("Menu2 clicked"); | |
}); | |
w.activity.actionBar.displayHomeAsUp = true; | |
w.activity.actionBar.onHomeIconItemSelected = function() { | |
alert("Home icon clicked"); | |
}; | |
}; | |
w.open(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment