package com.dooberz.z_day; import android.app.Activity; import android.content.Intent; import android.graphics.drawable.AnimationDrawable; import android.os.Bundle; import android.view.MotionEvent; import android.widget.ImageView; public class SplashActivity extends Activity { //The thread to process splash screen events private Thread mSplashThread; //Called when the activity is first created. @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //Splash screen view setContentView(R.layout.activity_splash); final SplashActivity splashScreen = this; final ImageView splashImageView = (ImageView) findViewById(R.id.SplashZombieImage); splashImageView.setBackgroundResource(R.drawable.zombie_anim); final AnimationDrawable frameAnimation = (AnimationDrawable)splashImageView.getBackground(); splashImageView.post(new Runnable() { @Override public void run() { frameAnimation.start(); } }); //The thread to wait for splash screen events mSplashThread = new Thread() { @Override public void run() { try{ synchronized(this) { //wait give period of time or exit on touch wait(5000); } } catch(InterruptedException e) {} finish(); //Run next Activity Intent intent = new Intent(); intent.setClass(splashScreen, MainActivity.class); startActivity(intent); } }; mSplashThread.start(); } //Processes splash screen touch events @Override public boolean onTouchEvent(MotionEvent evt) { if(evt.getAction() == MotionEvent.ACTION_DOWN) { synchronized(mSplashThread) { mSplashThread.notifyAll(); } } return true; } }
?xml version="1.0" encoding="utf-8"?> <animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/zombie_anim" android:oneshot="false" > <item android:drawable="@drawable/zombie_right1" android:duration="100"/> <item android:drawable="@drawable/zombie_right2" android:duration="100"/> <item android:drawable="@drawable/zombie_right3" android:duration="100"/> </animation-list>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)