Splash Screen


this is an example of an splashscreen i found on the internet, so i take no credit for this.

 

Image

Description: The code is somewhat self-expressive. Dont forget to add this new Activity in the AndroidManifest.xml :!:

“/res/layout/splashscreen.xml”:

  1. <?xml version=”1.0″ encoding=”utf-8″?>
  2. <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android&#8221;
  3.    android:orientation=”vertical”
  4.    android:layout_width=”fill_parent”
  5.    android:layout_height=”fill_parent”
  6.    >
  7.     <ImageView
  8.         android:layout_width=”fill_parent”
  9.         android:layout_height=”fill_parent”
  10.         android:scaleType=”fitCenter”
  11.         android:src=”@drawable/place_your_splashimage_here”
  12.         />
  13. </LinearLayout>

“/src/your_package_structure/Splash.java”:

Download

  1. package org.anddev.android.andnav;
  2. import android.app.Activity;
  3. import android.content.Intent;
  4. import android.os.Bundle;
  5. import android.os.Handler;
  6. public class Splash extends Activity {
  7.         // ===========================================================
  8.         // Fields
  9.         // ===========================================================
  10.         private final int SPLASH_DISPLAY_LENGHT = 1000;
  11.         // ===========================================================
  12.         // “Constructors”
  13.         // ===========================================================
  14.         /** Called when the activity is first created. */
  15.         @Override
  16.         public void onCreate(Bundle icicle) {
  17.                 super.onCreate(icicle);
  18.                 setContentView(R.layout.splashscreen);
  19.                 /* New Handler to start the Menu-Activity
  20.                  * and close this Splash-Screen after some seconds.*/
  21.                 new Handler().postDelayed(new Runnable(){
  22.                         @Override
  23.                         public void run() {
  24.                                 /* Create an Intent that will start the Menu-Activity. */
  25.                                 Intent mainIntent = new Intent(Splash.this,Menu.class);
  26.                                 Splash.this.startActivity(mainIntent);
  27.                                 Splash.this.finish();
  28.                         }
  29.                 }, SPLASH_DISPLAY_LENGHT);
  30.         }
  31. }

 

Original Post By plusminus at www.anddev.org

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: