---
title: "phonegap-splashscreen"
author: "fanfq"
date: "2012-11-02T14:20:47Z"
tags: []
categories: ["移动开发"]
slug: "phonegap-splashscreen"
draft: false
lastmod: "2012-11-02T14:20:47Z"
id: 1714451
url: "https://fanfq.iteye.com/blog/1714451"
---

其实就是自定义一个启动页面，不顾完全可以不用这么做，MainActivity就可以充当启动页面来做，这个是官方的例子就顺便学习一下。同时这里也有延迟加载的例子。 index.html \[code="html"] Splashscreen Example

# Example

\[/code] MainActivity.java \[code="java"] package com.fanfq.phonegap.splashscreen; import org.apache.cordova.DroidGap; import android.os.Bundle; public class MainActivity extends DroidGap { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // The first line 'super.setIntegerProperty' sets the image to be // displayed as the splashscreen. If you have named your image anything // other than splash.png you will have to modify this line. The second // line is the normal 'super.loadUrl' line but it has a second parameter // which is the timeout value for the splash screen. In this example the // splash screen will display for 10 seconds. If you want to dismiss the // splash screen once you get the "deviceready" event you should call // the navigator.splashscreen.hide() method. super.setIntegerProperty("splashscreen", R.drawable.splash); super.loadUrl("file:///android\_asset/www/index.html", 10000); } } \[/code]