美文网首页
Splash界面

Splash界面

作者: jsnow0613 | 来源:发表于2016-03-29 11:44 被阅读108次

    大多数的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); 
        }
    }
    

    相关文章

      网友评论

          本文标题:Splash界面

          本文链接:https://www.haomeiwen.com/subject/oahdlttx.html