Book Image

PhoneGap Mobile Application Development Cookbook

By : Matt Gifford
Book Image

PhoneGap Mobile Application Development Cookbook

By: Matt Gifford

Overview of this book

<p>As more and more of our online life and daily activities evolve into the mobile landscape it has never been of more importance to start venturing into the world of mobile applications.<br />&nbsp;<br />With PhoneGap, you can put your existing development skills and HTML, CSS, and JavaScript knowledge to great use by creating mobile apps for cross-platform devices.<br /><br />"PhoneGap Mobile Application Development Cookbook" will show you how to create native mobile applications for multiple device platforms using the PhoneGap API. You will learn to build dynamic applications that interact with the native functionality on the device to create a rich, interactive experience for your users.<br /><br />This is a cookbook with each section written as a recipe in an informal, friendly style. Each recipe contains the complete code needed to build your applications, and plenty of screenshots showing the completed projects running on devices are included to assist you.<br /><br />"PhoneGap Mobile Application Development Cookbook" will introduce the PhoneGap API to you in clear, concise sections, breaking down each recipe to achieve realistic working projects that can be applied to your own mobile applications.<br /><br />You will be shown how to use the mobile development framework to build applications that can be deployed and run on multiple mobile platforms including iOS, Android, and BlackBerry.<br /><br />This book will explore the various methods and functions available using the API, and how to write code that interacts with the native functions, including geolocation sensors, contacts database, and native button events of the device to create powerful applications ready for the market place.<br /><br />"PhoneGap Mobile Application Development Cookbook" will help you break into the world of mobile application development. Build mobile applications in code you&rsquo;re comfortable with, create a richer user experience for your users and become part of the ever-growing mobile market place.</p>
Table of Contents (17 chapters)
PhoneGap Mobile Application Development Cookbook
Credits
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Creating a custom submenu


Your application may include an option for users to update or change settings, or perhaps the ability to truly exit the application gracefully, closing down all services and storing state or data.

How to do it...

In this recipe, we will create a simple application that interacts with the device's native menu button to create a sliding submenu:

  1. Create the initial layout of the HTML for our application. Include the Cordova and XUI JavaScript library references in the head of the document, and include an onLoad method call within the body tag, which will set the deviceready event listener once the DOM is fully loaded.

    <!DOCTYPE HTML>
    <html>
      <head>
        <meta name="viewport" content="user-scalable=no, 
             initial-scale=1, maximum-scale=1, 
             minimum-scale=1, width=device-width;" />
        <meta http-equiv="Content-type" content="text/html; 
        charset=utf-8">
        <title>Sub Menu</title>
        <script type="text/javascript...