Splash界面

2016-03-29  本文已影响108人  jsnow0613

大多数的Splash界面都是会等待一定时间,然后切换到下一个界面;其实,在这段时间里,可以对系统状况进行检测,比如网络是否通,电源是否充足;或者,预先加载相关数据;

源码示例

AndroidMenifest.xml

<activity android:icon="@drawable/app_icon"
          android:screenOrientation="portrait"
          android:name=".splashScreen"
          android:theme="@android:style/Theme.NoTitleBar">
          <intent-filter>
              <action android:name="android.intent.action.MAIN"/>
              <category android:name="android.intent.category.LAUNCHER"/>
          </intent-filter>
</activity>

splashScreen.java

public class splashScreen extends Activity {
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        setContentView(R.layout.splashscreen);

        new Handler().postDelayed(new Runnable() {
            public void run() {
                Intent intent = new Intent(splashScreen.this, MainActivity.class);
                startActivity(intent);
                finish();
            }
        }, 2000); 
    }
}
上一篇下一篇

猜你喜欢

热点阅读