- Grab the latest version of the module from https://github.com/ricardoalcocer/actionbarextras/tree/master/dist
- Create a new Alloy project and use this file as index.js. This code is using the Chunkfive.otf custom font, which you can download for free from http://www.fontsquirrel.com/fonts/download/ChunkFive and save it to app/assets/android/fonts
Last active
August 29, 2015 14:04
-
-
Save ricardoalcocer/a7258c0cb7909e86ced2 to your computer and use it in GitHub Desktop.
Using ActionBarExtras (https://github.com/ricardoalcocer/actionbarextras)
This file contains 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
function doClick(e) { | |
alert($.label.text); | |
} | |
// load the module | |
var abextras = require('com.alcoapps.actionbarextras'); | |
$.index.addEventListener('open',function(evt){ | |
// set extras once the Activity is available | |
abextras.title = "ActionbarExtras"; | |
abextras.titleFont = "Chunkfive.otf"; | |
abextras.titleColor="#840505"; | |
abextras.subtitle = "for some extra action"; | |
abextras.subtitleFont = "Chunkfive.otf"; | |
abextras.subtitleColor="#562A2A"; | |
abextras.backgroundColor="#F49127" | |
// disable the App Icon | |
//abextras.setDisableIcon(); | |
// now set the menus | |
evt.source.activity.onCreateOptionsMenu = function(e){ | |
// aboutBtn and creditsBtn will be displayed in the menu overflow | |
aboutBtn = e.menu.add({ | |
title : "About", | |
showAsAction : Ti.Android.SHOW_AS_ACTION_NEVER | |
}); | |
aboutBtn.addEventListener("click", function(e) { | |
console.log('Clicked on About') | |
}); | |
creditsBtn = e.menu.add({ | |
title : "Credits", | |
showAsAction : Ti.Android.SHOW_AS_ACTION_NEVER | |
}); | |
creditsBtn.addEventListener("click", function(e) { | |
console.log('Clicked on Credits') | |
}); | |
// create the Share intent and add it to the ActionBar | |
var intent = Ti.Android.createIntent({ | |
action: Ti.Android.ACTION_SEND, | |
type: 'text/plain' | |
}); | |
intent.putExtra(Ti.Android.EXTRA_TEXT, 'Hello world!'); | |
abextras.addShareAction({ | |
menu: e.menu, | |
intent: intent | |
}); | |
}; | |
}) | |
$.index.open(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment