jQuerymobile
Integrating Android with
The Android market is growing steadily. Every day, new technologies and new frameworks are being introduced. Currently, the application’s beauty, creativity and interactivity are as important as its functionality in order for it to provide the best user experience. Among the several Android development platforms, JQuery Mobile can make your application amazingly beautiful. With a user interface system that works seamlessly across all mobile device platforms, it provides a very feature-rich development environment. This article demonstrates the use of JQuery Mobile with PhoneGap.
My system has the following software: the Linux distro is the Ubuntu 10.10 32-bit desktop version; I use Eclipse Indigo, and my Android version is 2.2 (though this can be applied to 2.3 also). The PhoneGap version is 0.9.3 and JQuery Mobile is version 1.2.0. The information aQG LPaJHV LQ WhLV aUWLFOH aUH wLWh UHVpHFW WR WhLV FRQfiJXUaWLRQ.
Getting started
The framework provides a set of touch-friendly UI widgets and includes list-views, buttons, form elements, transitions, themes, pages, dialogue boxes, toolbars and an AJAX-powered navigation system to support animated page transitions. To get started with JQuery Mobile, let’s try a simple HTML page. In your text-editor, enter the Page-Template (index.html) given below, save it and open in a browser: <!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”> <html> <head> <title>My Page</title> <meta name=”viewport” content=”width=device-width, initialscale=1”> <link rel=”stylesheet” href=”jquery.mobile-1.2.0.min.css”/> <script src=”jquery-1.8.2.min.js”></script> <script src=”jquery.mobile-1.2.0.min.js”></script> </head> <body> <div data-role=”page”> <div data-role=”header”>
<h1>My Title</h1> </div><!-- /header --> <div data-role=”content”>
<p>Hello Phonegap</p>
To help newbies understand the template, let me explain a little more in detail. In the head, a meta viewport tag sets the screen width to the pixel width of the device. The stylesheet is added since it is needed to implement JQuery effects. We reference the JQuery and JQuery Mobile scripts to add their functionality. As a normal page, it contains a header, body and footer. Here, the data-role=”page” wUappHU VLJQLfiHV WhaW a paJH is going to be delineated. The data-role=”header” VLJQLfiHV a header tag, while data-role=”content” VLJQLfiHV a ERGy IRU WhH whole content. Inside this content container, you can add any standard HTML elements—headings, lists, paragraphs, etc.
Let’s proceed to build, implement and run this JQueryenabled HTML page in the Android emulator.
Building and configuring
ThH fiUVW WhLQJ LV WR GRwQORaG aQG LQVWaOO WhH AQGURLG SD.—WhH software development kit that provides the necessary tools for development, and comes in different versions for Windows, LLQXx aQG 0aF 2S. ThHQ wH QHHG WR LQVWaOO aQ ,D(—, XVH (FOLpVH. DRwQORaG aQG LQVWaOO (FOLpVH, WhHQ OaXQFh LW aQG RpHQ LWV wRUNEHQFh. DRwQORaG aQG LQVWaOO WhH ADT pOXJ-LQ IRU (FOLpVH. Next, download the PhoneGap package—the cross-platform IUaPHwRUN XVHG WR FUHaWH paFNaJH fiOHV WR LQVWaOO yRXU appOLFaWLRQ RQ GLIIHUHQW PRELOH 2SV OLNH AQGURLG, L2S, BOaFNEHUUy, HWF. AOVR GRwQORaG WhH -QXHUy 0RELOH pUH-GHfiQHG min.js and min.css fiOHV used in our index.html page.
Now that we have all the ingredients, we can start with LQWHJUaWLRQ. SWaUW (FOLpVH aQG FhRRVH yRXU wRUNVpaFH. GR WR File > New >Android Project. SpHFLIy a Project Name (e.g., My First