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

Working with touch and gesture events


When working with user interfaces that demand a high level of user interaction or certain processes to be run at certain moments, we need to start looking at using events and detecting them to execute methods. In this recipe we will create some functionality that will demonstrate not only setting an event, but removing it as well.

How to do it...

We will use the methods available in the XUI library to control the delegation of event handlers.

  1. Create the HTML layout for your application. Include the XUI and Cordova JavaScript libraries within the head tag of your document.

  2. Add an empty script tag block before the closing head tag. This will hold our custom PhoneGap code. Within this, define a new onLoad function.

  3. Add an on event handler, which will run the onLoad JavaScript method when the DOM has fully loaded.

  4. Finally, add a new button element within the body of the document. Set the id attribute to touchme.

    <!DOCTYPE HTML>
    <html>
      <head&gt...