Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> 關於Android編程 >> Android PhoneGap event in the Code

Android PhoneGap event in the Code

編輯:關於Android編程

print?<!DOCTYPE html> 
<html> 
<head> 
<title>PhoneGap Event Example</title> 
 
<script type="text/javascript" charset="utf-8" src="cordova.js"></script> 
<script type="text/javascript" charset="utf-8"> 
   document.addEventListener("deviceready",onDeviceReady,false); 
    
   function onDeviceReady(){ 
       //To detect when the device is ready, use the  deviceready event. 
       document.addEventListener("pause",onPause,false); 
       document.addEventListener("resume",onResume,false); 
       document.addEventListener("backbutton",onBackButton,false); 
       document.addEventListener("menubutton",onMenuButton,false); 
       document.addEventListener("searchbutton",onSearchButton,false); 
       document.addEventListener("online",isOnline,false); 
       document.addEventListener("offline",isOffline,false); 
   } 
    
   function onPause(){ 
       //To detect when the application has been paused, use the  pause event. 
   } 
    
   function onResume(){ 
       //To detect when the application has been resumed, use the resume event. 
   } 
    
   function onBackButton() 
   { 
       //To detect when the Back button has been pressed on an Android device,use the backbutton event. 
       alert("onBackButton!"); 
   } 
    
   function onMenuButton(){ 
       //To detect when the Menu button has been pressed on an Android device,use the menubutton event. 
       alert("onMenuButton"); 
   } 
    
   function onSearchButton(){ 
       //To detect when the Search button has been pressed on an Android device, use the searchbutton event. 
   } 
    
   function isOnline(){ 
       //To detect when the application is online (connected to the Internet), use the online event. 
   } 
    
   function isOffline(){ 
       //To detect when the application is ol  ine (not connected to the Internet),use the offline event. 
   } 
    
</script> 
</head> 
<body> 
  <h1>PhoneGap Event Example</h1> 
</body> 
</html> 

<!DOCTYPE html>
<html>
<head>
<title>PhoneGap Event Example</title>

<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script type="text/javascript" charset="utf-8">
   document.addEventListener("deviceready",onDeviceReady,false);
  
   function onDeviceReady(){
    //To detect when the device is ready, use the  deviceready event.
    document.addEventListener("pause",onPause,false);
    document.addEventListener("resume",onResume,false);
    document.addEventListener("backbutton",onBackButton,false);
    document.addEventListener("menubutton",onMenuButton,false);
    document.addEventListener("searchbutton",onSearchButton,false);
    document.addEventListener("online",isOnline,false);
    document.addEventListener("offline",isOffline,false);
   }
  
   function onPause(){
    //To detect when the application has been paused, use the  pause event.
   }
  
   function onResume(){
    //To detect when the application has been resumed, use the resume event.
   }
  
   function onBackButton()
   {
    //To detect when the Back button has been pressed on an Android device,use the backbutton event.
    alert("onBackButton!");
   }
  
   function onMenuButton(){
    //To detect when the Menu button has been pressed on an Android device,use the menubutton event.
    alert("onMenuButton");
   }
  
   function onSearchButton(){
    //To detect when the Search button has been pressed on an Android device, use the searchbutton event.
   }
  
   function isOnline(){
    //To detect when the application is online (connected to the Internet), use the online event.
   }
  
   function isOffline(){
    //To detect when the application is ol  ine (not connected to the Internet),use the offline event.
   }
  
</script>
</head>
<body>
  <h1>PhoneGap Event Example</h1>
</body>
</html>


 

  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved