基本信息
源码名称:PhoneGap 开发android应用例子源码下载
源码大小:0.79M
文件格式:.zip
开发语言:Java
更新时间:2014-11-04
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
(1)把phonegap的jar包和xml文件放到工程下的正确目录;
(2)修改src下的android默认类 DroidGap
(3)在aseets下面建立工程的根目录www,并在其中放入js、html、image、css等普通的web文件;
(4)只需要在index页面加入js包和css文件,其他页面只需要组织成一个简单的jQuery Mobile页面。
(5)调用一些特殊的api时,需要注意申请android许可!
html代码:
<!Doctype html> <html> <head> <title>Phone Gap Introduce</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <link rel="stylesheet" type="text/css" href="../JS/jquery.mobile-1.0rc1.min.css"/> <script type="text/javascript" src="../JS/jquery_1_6_4.js"></script> <script type="text/javascript" src="../JS/phonegap-1.2.0.js"></script> <script type="text/javascript" src="../JS/jquery.mobile-1.0rc1.js"></script> <script type="text/javascript"> $('#PageOne').live('pageinit', function(event){ var showTip = function(){ navigator.notification.alert("this is a message from page one!", null, "Message", "Close"); $(this).die("click"); }; var confirm = function(){ navigator.notification.confirm( 'You are the winner!', // message null, // callback to invoke with index of button pressed 'Game Over', // title 'Restart,Exit' // buttonLabels ); $(this).die("click"); }; var redirectPage = function(){ $.mobile.changePage("#PageTwo"); $(this).die("click"); }; $(event.target).find('#alert').bind('click', showTip); $(event.target).find('#confirm').bind('click', confirm); $(event.target).find('#changePage').bind('click', redirectPage); }); $('#PageTwo').live('pageshow', function(event){ var showTip = function(){ navigator.notification.alert("this is a message from page two!", null, "Message", "Close"); $(this).die("click"); }; var confirm = function(){ navigator.notification.confirm( 'You are the losser!', // message null, // callback to invoke with index of button pressed 'Game Over', // title 'Restart,Exit' // buttonLabels ); $(this).die("click"); }; $(event.target).find('#alert').bind('click', showTip); $(event.target).find('#confirm').bind('click', confirm); }); </script> </head> <body> <div id="PageOne" data-role="page"> <div data-role="header" data-backbtn="false"> <h1>Phone Gap One</h1> </div> <div data-role="content"> <div> <a href="#" id="alert" data-role="button" data-theme="b">Alert</a> </div> <div> <a href="#" id="confirm" data-role="button" data-theme="b">Confirm</a> </div> <div> <a href="#" id="changePage" data-role="button" data-theme="b">Change Page</a> </div> </div> <div data-role="footer"> <div data-role="navbar"> <ul> <li><a href="#PageOne">Page One</a></li> <li><a href="#PageTwo">Page Two</a></li> </ul> </div> </div> </div> <div id="PageTwo" data-role="page"> <div data-role="header" data-backbtn="true"> <h1>Phone Gap Two</h1> <a data-role="button" data-rel="back">Previous</a> </div> <div data-role="content"> <div> <a href="#" id="alert" data-role="button" data-theme="b">Alert</a> </div> <div> <a href="#" id="confirm" data-role="button" data-theme="b">Confirm</a> </div> <div> <a href="file:///android_asset/www/Pages/pageThree.html" data-role="button" data-theme="b">Page Three</a> </div> </div> <div data-role="footer"> <div data-role="navbar"> <ul> <li><a href="#PageOne">Page One</a></li> <li><a href="#PageTwo">Page Two</a></li> </ul> </div> </div> </div> </body> </html>
java代码:
package com.kiddyu.app; import com.phonegap.DroidGap; import android.os.Bundle; public class IntroduceActivity extends DroidGap { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); super.loadUrl("file:///android_asset/www/Pages/index.html"); } }