Android Popup Menu module for Titanium

Android Popup Menu is a menu that need to be attached to an anchor view.

popup-menu popup-menu-abmenuitem

var win = Ti.UI.createWindow({
    exitOnClose: true,
    title: 'PopupMenu'

var popup = require('nc.popup');

var btn = Ti.UI.createButton({
    title: 'Show popup'
btn.addEventListener('click', function() {
    var menu = popup.createPopupMenu({
        options: ['Item A', 'Item B', 'Item C'],
        view: btn
    menu.addEventListener('click', function(e) {
        alert('Selected item: '+e.index);
    menu.addEventListener('dismiss', function() {
        alert('popup menu has been dismissed');

win.addEventListener('open', function() {
    var activity = this.activity;
    if (activity) {
        activity.onCreateOptionsMenu = function(e) {
            var addMenu ={
                title: 'Add',
                showAsAction: Ti.Android.SHOW_AS_ACTION_ALWAYS
            addMenu.addEventListener('click', function() {
                var menu = popup.createPopupMenu({
                    options: ['User', 'Project', 'Item'],
                    view: addMenu
                menu.addEventListener('click', function(e) {
          'Selected item: '+e.index);

Download from Github

(my first open source Titanium module <o/)

Share this...
Share on FacebookTweet about this on TwitterShare on Google+Share on LinkedInPin on Pinterest

Leave a Reply

Your email address will not be published. Required fields are marked *