You want to execute a delayed task that executes its logic only after a certain amountof time has passed.

The splash image can be dropped in the res/drawables folder:splash.png

The layout for a splash screen Activity:splash_screen.xml:

<?xml version="1.0" encoding="utf-8"?><merge xmlns:android="http://schemas.android.com/apk/res/android">  <ImageView     android:layout_width="fill_parent"    android:layout_height="fill_parent"     android:scaleType="fitXY"    android:src="@drawable/splash" /></merge>
We also need to define the new Activity in the manifestfile. Because it’ll be the first Activity that’s launched, it’ll take the place of theMyMovies Activity.
......... <activity            android:name=".SplashScreen"            android:label="@string/title_myMovie"             android:theme="@style/SplashScreen">            <intent-filter>                <action android:name="android.intent.action.MAIN" />                <category android:name="android.intent.category.LAUNCHER" />            </intent-filter>        </activity>         <activity android:name=".MyMovies" />.........

We want the splash screen to befullscreen, so add the following code to your styles.xml:

<style name="SplashScreen" parent="@android:style/Theme.Black"><item name="android:windowNoTitle">true</item></style>

create the activity class SplashScreen

public class SplashScreen extends Activity { public static final int SPLASH_TIMEOUT = 2000;   @Override   protected void onCreate(Bundle savedInstanceState) {      super.onCreate(savedInstanceState);      setContentView(R.layout.splash_screen);            new Timer().schedule(new TimerTask(){@Overridepublic void run() {// TODO Auto-generated method stubproceed();}            }, SPLASH_TIMEOUT);   }   public boolean onTouchEvent(MotionEvent event){   if(event.getAction()==MotionEvent.ACTION_DOWN){   proceed();   }   return super.onTouchEvent(event);   }   private void proceed() {   if(this.isFinishing()){   return;   }   startActivity(new Intent(SplashScreen.this,MyMovies.class));   finish();   }}

The task itself creates an Intent to launch our landingscreen (the MyMovies main Activity).

更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. 基于Android的OpenGL—使用GLSurfaceView
  2. Android读取文本文件中内容的方法
  3. android shape的使用详解以及常用效果(渐
  4. Android ANR简介
  5. Android之安全机制
  6. Android的Ui高级控件
  7. android 自定义View 之自定义属性
  8. 去除MTK Android 自带Launcher用自己的La
  9. Android中的广播
  10. android语音识别简单实现