0
点赞
收藏
分享

微信扫一扫

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
2.   
3. import
4.   
5. import
6.   
7. public class MainActivity extends
8. @Override
9. public void
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. }



  • splashscreen.zip (4.6 MB)
  • 下载次数: 26
举报

相关推荐

0 条评论