【发布时间】:2014-09-16 22:41:42
【问题描述】:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
new Handler().postDelayed(new Runnable() {
/*
* Showing splash screen with a timer. This will be useful when you
* want to show case your app logo / company
*/
@Override
public void run() {
// This method will be executed once the timer is over
// Start your app main activity
Intent i = new Intent(SplashScreen.this, MainActivity.class);
startActivity(i);
// close this activity
finish();
}
}, SPLASH_TIME_OUT);
}
【问题讨论】:
-
您遇到了什么问题?
-
我是 android 新手,我想设计 spalash 屏幕,我看不懂这段代码
-
是的,它在 SPLASH_TIME_OUT 毫秒内开始一个新的活动,并结束这个活动。它是一个闪屏实现。应该可以很好地工作,除非用户在此过程中不断旋转手机,在这种情况下,它会保持打开的时间过长。
-
您应该更具体地说明哪些部分让您感到困惑,然后将标题调整为不那么宽泛
-
这个问题似乎跑题了,因为它是关于解释代码的。