我使用代碼被髮布在堆棧溢出的android應用程序的啓動屏幕的代碼。我無法獲得輸出。這是代碼。在android中的飛濺屏幕不工作
package com.splash;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
public class SplashScreen extends Activity {
private static final int SPLASH_DISPLAY_TIME = 3000;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
new Handler().postDelayed(new Runnable() {
public void run() {
Intent mainIntent = new Intent(Splashscreen.this,
MainActivity.class);
Splashscreen.this.startActivity(mainIntent);
Splashscreen.this.finish();
overridePendingTransition(R.anim.mainfadein,
R.anim.splashfadeout);
}
}, SPLASH_DISPLAY_TIME);
}
}
}
這是splash.xml文件;
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="@drawable/splash" />
</LinearLayout>
請告訴我如何解決它。我也有淡入淡出的xml文件,用於啓動屏幕圖像。
在你的代碼
「public class SplashScreen extends Activity {」double is typo error? –