Android Popup Menu module for Titanium
On 16 September 2014 in TechAndroid Popup Menu is a menu that need to be attached to an anchor view.
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'); }); menu.show(); }); win.add(btn); win.addEventListener('open', function() { var activity = this.activity; if (activity) { activity.onCreateOptionsMenu = function(e) { var addMenu = e.menu.add({ 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) { Ti.API.info('Selected item: '+e.index); }); menu.show(); }); }; } }); win.open();
(my first open source Titanium module <o/)
Related posts:
-
ActionBarImplBase can only be used with a compatible window decor layout
-
Creating [object] in a different context than the calling function.
-
Setup Titanium Studio environment for developing Titanium module (Android) on Windows
-
Android Progress Notification module
-
Titanium iOS “build” is an unrecognized command
-
Logcat
-
Titanium app hex color value with alpha channel
-
Titanium iOS builder script
-
Designing web page for Android webview
-
Add project as library – Titanium module (Android)
Filed under Tech with tags Android, PopupView, Titanium Mobile, Titanium Module
Leave a Reply