phonegap-splashscreen

其实就是自定义一个启动页面,不顾完全可以不用这么做,MainActivity就可以充当启动页面来做,这个是官方的例子就顺便学习一下。同时这里也有延迟加载的例子。 

index.html 
Html代码   收藏代码
  1. <!DOCTYPE html>  
  2. <html>  
  3.   <head>  
  4.     <title>Splashscreen Example</title>  
  5.   
  6.     <script type="text/javascript" charset="utf-8" src="cordova-2.0.0.js"></script>  
  7.     <script type="text/javascript" charset="utf-8">  
  8.   
  9.     // Wait for Cordova to load  
  10.     //  
  11.     document.addEventListener("deviceready", onDeviceReady, false);  
  12.   
  13.     // Cordova is ready  
  14.     //  
  15.     function onDeviceReady() {  
  16.         //navigator.splashscreen.show();  
  17.         navigator.splashscreen.hide();  
  18.     }  
  19.   
  20.     </script>  
  21.   </head>  
  22.   <body>  
  23.     <h1>Example</h1>  
  24.   </body>  
  25. </html>  


MainActivity.java 
Java代码   收藏代码
  1. package com.fanfq.phonegap.splashscreen;  
  2.   
  3. import org.apache.cordova.DroidGap;  
  4.   
  5. import android.os.Bundle;  
  6.   
  7. public class MainActivity extends DroidGap {  
  8.     @Override  
  9.     public void onCreate(Bundle savedInstanceState) {  
  10.         super.onCreate(savedInstanceState);  
  11.         // The first line 'super.setIntegerProperty' sets the image to be  
  12.         // displayed as the splashscreen. If you have named your image anything  
  13.         // other than splash.png you will have to modify this line. The second  
  14.         // line is the normal 'super.loadUrl' line but it has a second parameter  
  15.         // which is the timeout value for the splash screen. In this example the  
  16.         // splash screen will display for 10 seconds. If you want to dismiss the  
  17.         // splash screen once you get the "deviceready" event you should call  
  18.         // the navigator.splashscreen.hide() method.  
  19.         super.setIntegerProperty("splashscreen", R.drawable.splash);  
  20.         super.loadUrl("file:///android_asset/www/index.html"10000);  
  21.     }  
  22. }  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值