OpenSource For You

jQuerymobi­le

Integratin­g Android with

-

The Android market is growing steadily. Every day, new technologi­es and new frameworks are being introduced. Currently, the applicatio­n’s beauty, creativity and interactiv­ity are as important as its functional­ity in order for it to provide the best user experience. Among the several Android developmen­t platforms, JQuery Mobile can make your applicatio­n amazingly beautiful. With a user interface system that works seamlessly across all mobile device platforms, it provides a very feature-rich developmen­t environmen­t. This article demonstrat­es 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 informatio­n aQG LPaJHV LQ WhLV aUWLFOH aUH wLWh UHVpHFW WR WhLV FRQfiJXUaW­LRQ.

Getting started

The framework provides a set of touch-friendly UI widgets and includes list-views, buttons, form elements, transition­s, themes, pages, dialogue boxes, toolbars and an AJAX-powered navigation system to support animated page transition­s. 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 Transition­al//EN” “http://www.w3.org/TR/html4/loose.dtd”> <html> <head> <title>My Page</title> <meta name=”viewport” content=”width=device-width, initialsca­le=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 functional­ity. 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 JQueryenab­led HTML page in the Android emulator.

Building and configurin­g

ThH fiUVW WhLQJ LV WR GRwQORaG aQG LQVWaOO WhH AQGURLG SD.—WhH software developmen­t kit that provides the necessary tools for developmen­t, 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 appOLFaWLR­Q 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 ingredient­s, we can start with LQWHJUaWLR­Q. SWaUW (FOLpVH aQG FhRRVH yRXU wRUNVpaFH. GR WR File > New >Android Project. SpHFLIy a Project Name (e.g., My First

 ??  ?? </div><!-- /content --> </div><!-- /page --> </body> </html>
</div><!-- /content --> </div><!-- /page --> </body> </html>

Newspapers in English

Newspapers from India