ThienThanCNTT
Bạn có muốn phản ứng với tin nhắn này? Vui lòng đăng ký diễn đàn trong một vài cú nhấp chuột hoặc đăng nhập để tiếp tục.

PhoneGap on Android

Go down

PhoneGap on Android Empty PhoneGap on Android

Bài gửi by nth 17/10/11, 11:48 am

hjx, bài đầu tiên, sau khi chạy được ví dụ của phonegap, bài đầu tiên là helloworld, và cho người dùng nhấp chọn oki sau khi chạy thành công. Code (script)
<script type="text/javascript">
document.addEventListener("deviceready", function () {
alert('Our first PhoneGap app');
}, false);
</script>


Được sửa bởi nth ngày 17/10/11, 02:41 pm; sửa lần 1.
nth
nth
Admin
Admin

Tổng số bài gửi : 550
Số điểm : 1113
Số lần được cám ơn : 33
Ngày đến diễn đàn: : 01/08/2009
Tuổi : 35
Đến từ : Thiên Đường

https://thuhuong.forumvi.net

Về Đầu Trang Go down

PhoneGap on Android Empty Accelerometer

Bài gửi by nth 17/10/11, 02:29 pm

Captures device motion in the x, y, and z direction.
<head>
<title>PhoneGap</title>
<script type="text/javascript" charset="utf-8" src="phonegap-1.1.0.js"></script>
<script type="text/javascript">
var watchID = null;
document.addEventListener("deviceready",onDeviceReady,false);
function onDeviceReady(){
navigator.accelerometer.getCurrentAcceleration(onSuccess,onError);
};
function startWatch(){
var options = {frequency:3000}; // update moi lan 3s
watchID = navigator.accelermoter.watchAcceleration(onSuccess,onError,options);
};
function stopWatch(){
if(watchID){
navigator.accelerometer.clearWatch(watchID);
watchID = null;
}
};
function onSuccess(acceleration){
alert('Acceleration X: '+acceleration.x + '\n'+
'Acceleration Y: '+acceleration.y+'\n'+
'Acceleration Z: '+acceleration.z+'\n'+
'Timestamp: '+acceleration.timestamp+'\n');
};
function onError(){
alert('onError!');
};

</script>
</head>
<body>
<h1>Hello World</h1>
<div id = "accelerometer">vui long cho..</div>
<button onclick="stopWatch();">Stop Watching</button>
</body>
nth
nth
Admin
Admin

Tổng số bài gửi : 550
Số điểm : 1113
Số lần được cám ơn : 33
Ngày đến diễn đàn: : 01/08/2009
Tuổi : 35
Đến từ : Thiên Đường

https://thuhuong.forumvi.net

Về Đầu Trang Go down

PhoneGap on Android Empty Re: PhoneGap on Android

Bài gửi by nth 17/10/11, 03:02 pm

<script type="text/javascript" charset="utf-8" src="phonegap-1.1.0.js"></script>
<script type="text/javascript" charset="utf-8" src="phonegap.js"></script>

<script type="text/javascript" charset="utf-8">
var displayHello = function() {
var name = document.getElementById("firstname").value;
navigator.notification.alert("name " + name);
}
</script>
</head>
<body onload="init();" id="bdy" >
<div id="txt">
<input type="text" name="firstname" id="firstname" />
</div>
<div id ="btn">
<a href="#" class="btn" onclick="displayHello();">Say Hello</a>
</div>
nth
nth
Admin
Admin

Tổng số bài gửi : 550
Số điểm : 1113
Số lần được cám ơn : 33
Ngày đến diễn đàn: : 01/08/2009
Tuổi : 35
Đến từ : Thiên Đường

https://thuhuong.forumvi.net

Về Đầu Trang Go down

PhoneGap on Android Empty Re: PhoneGap on Android

Bài gửi by nth 17/10/11, 03:56 pm

load 1 trang web ngay trong phonegap, dùng webview
[You must be registered and logged in to see this link.]
nth
nth
Admin
Admin

Tổng số bài gửi : 550
Số điểm : 1113
Số lần được cám ơn : 33
Ngày đến diễn đàn: : 01/08/2009
Tuổi : 35
Đến từ : Thiên Đường

https://thuhuong.forumvi.net

Về Đầu Trang Go down

PhoneGap on Android Empty Re: PhoneGap on Android

Bài gửi by Sponsored content


Sponsored content


Về Đầu Trang Go down

Về Đầu Trang


 
Permissions in this forum:
Bạn không có quyền trả lời bài viết