我有下面的代码,它创建了一个启动画面。当我启动我的应用程序时,我看不到启动屏幕,而是直接看到第一个活动:
public class splash extends Activity {
private static final int STOPSPLASH = 0;
//time in milliseconds
private static final long SPLASHTIME = 13000;
private ImageView splash;
//handler for splash screen
private Handler splashHandler = new Handler() {
/* (non-Javadoc)
* @see android.os.Handler#handleMessage(android.os.Message)
*/
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case STOPSPLASH:
//remove SplashScreen from view
splash.setVisibility(View.GONE);
break;
}
super.handleMessage(msg);
}
};
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
Intent intent = new Intent(this, prima.class);
splash = (ImageView) findViewById(R.id.imageView1);
Message msg = new Message();
msg.what = STOPSPLASH;
splashHandler.sendMessageDelayed(msg, SPLASHTIME);
startActivity(intent);
}
}