美文网首页
Android启动页

Android启动页

作者: Rambo_Y | 来源:发表于2018-04-10 14:16 被阅读0次

在清单文件中配置

     //启动页
        <activity android:name=".activity.LunachActivity">
            android:screenOrientation="portrait"
            android:theme="@style/AppTheme.NoTitle.Fullscreen">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

LaunchActivity.java

public class LunachActivity extends AppCompatActivity {

    private static final long SPLASH_DELAY_MILLIS = 3000;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_lunach);

        // 使用Handler的postDelayed方法,3秒后执行跳转到MainActivity
        new Handler().postDelayed(new Runnable() {
            public void run() {
                goHome();
            }
        }, SPLASH_DELAY_MILLIS);
    }
    private void goHome() {
        Intent intent = new Intent(LunachActivity.this, MainActivity.class);
        LunachActivity.this.startActivity(intent);
        LunachActivity.this.finish();
    }

}

相关文章

网友评论

      本文标题:Android启动页

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