Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Appcelerator Titanium Application Development by Example Beginner's Guide

You're reading from   Appcelerator Titanium Application Development by Example Beginner's Guide Once you've got into Appcelerator Titanium you'll never look back. This book is the perfect introduction to developing native cross-platform apps for iOS, Android, and Windows 8.

Arrow left icon
Product type Paperback
Published in Apr 2013
Publisher Packt
ISBN-13 9781849695008
Length 334 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Darren Paul Cope Darren Paul Cope
Author Profile Icon Darren Paul Cope
Darren Paul Cope
Arrow right icon
View More author details
Toc

Table of Contents (23) Chapters Close

Appcelerator Titanium Application Development by Example Beginner's Guide
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
1. How to Get Up and Running with Titanium 2. How to Make an Interface FREE CHAPTER 3. How to Design Titanium Apps 4. Gluing Your App Together with Events, Variables, and Callbacks 5. It's All About Data 6. Cloud-enabling Your Apps 7. Putting the Phone Gadgets to Good Use 8. Creating Beautiful Interfaces 9. Spread the Word with Social Media 10. Sending Notifications 11. Testing and Deploying 12. Analytics 13. Making Money from Your App Git Integration Glossary
Pop Quiz Answers Index

Time for action – adding an Android menu


Perform the following steps for adding an Android menu:

  1. Add a function that will define the pop-up menu:

    function addMenu(win) {
        var activity = win.activity;
    
        activity.onCreateOptionsMenu = function(e){
    
        var firstItem = e.menu.add({ title: 'First Item' });
        firstItem.addEventListener("click", function(e) {Ti.API.debug('First Item'); });
        
        var secondItem = e.menu.add({ title: 'Second Item'});
        secondItem.addEventListener("click", function(e) {Ti.API.warn('Second Item'); });
        
        var thirdItem = e.menu.add({ title: 'Third Item'});
        thirdItem.addEventListener("click", function(e) {alert('Third Item'); });
    };
    }
  2. Further down app.js where the windows are defined, add the highlighted code to call the function:

    win1.add(label1);
    addMenu(win1);
    
  3. Run the app using the Android emulator.

What just happened?

A pop-up menu was created that is activated by pressing the menu key when Tab 1 is selected. The pop-up menu has three items and...

You have been reading a chapter from
Appcelerator Titanium Application Development by Example Beginner's Guide
Published in: Apr 2013
Publisher: Packt
ISBN-13: 9781849695008
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image