Book Image

PhoneGap 4 Mobile Application Development Cookbook

Book Image

PhoneGap 4 Mobile Application Development Cookbook

Overview of this book

Table of Contents (19 chapters)
PhoneGap 4 Mobile Application Development Cookbook
Credits
About the Authors
About the Reviewer
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 by 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. Firstly, create a new PhoneGap project named submenu by running the following command:

    phonegap create submenu com.myapp.submenu submenu
    
  2. Add a devices platform. You can choose to use Android as follows:

    cordova platform add android
    
  3. Open www/index.html and let's clean up unnecessary elements. We'll also manipulate the DOM elements, so include a reference to the xui.js file within the head tag. We will 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 charset="utf-8" />
            &lt...