添加启动画面后,我的应用程序崩溃。下面是错误日志、xml 和 java 文件。我在其他应用程序中大多使用相同的代码,但我不明白为什么它在这里不起作用请帮助
04-09 20:36:05.469: E/AndroidRuntime(27529): FATAL EXCEPTION: main
04-09 20:36:05.469: E/AndroidRuntime(27529): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.zaidi.mindmapmaker/com.behram.mindmapmaker.SplashScreen}: android.view.InflateException: Binary XML file line #8: Error inflating class <unknown>
04-09 20:36:05.469: E/AndroidRuntime(27529): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
04-09 20:36:05.469: E/AndroidRuntime(27529): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
04-09 20:36:05.469: E/AndroidRuntime(27529): at android.app.ActivityThread.access$600(ActivityThread.java:123)
04-09 20:36:05.469: E/AndroidRuntime(27529): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
04-09 20:36:05.469: E/AndroidRuntime(27529): at android.os.Handler.dispatchMessage(Handler.java:99)
04-09 20:36:05.469: E/AndroidRuntime(27529): at android.os.Looper.loop(Looper.java:137)
04-09 20:36:05.469: E/AndroidRuntime(27529): at android.app.ActivityThread.main(ActivityThread.java:4424)
04-09 20:36:05.469: E/AndroidRuntime(27529): at java.lang.reflect.Method.invokeNative(Native Method)
04-09 20:36:05.469: E/AndroidRuntime(27529): at java.lang.reflect.Method.invoke(Method.java:511)
04-09 20:36:05.469: E/AndroidRuntime(27529): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:825)
04-09 20:36:05.469: E/AndroidRuntime(27529): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:592)
04-09 20:36:05.469: E/AndroidRuntime(27529): at dalvik.system.NativeStart.main(Native Method)
04-09 20:36:05.469: E/AndroidRuntime(27529): Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class <unknown>
04-09 20:36:05.469: E/AndroidRuntime(27529): at android.view.LayoutInflater.createView(LayoutInflater.java:606)
04-09 20:36:05.469: E/AndroidRuntime(27529): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
04-09 20:36:05.469: E/AndroidRuntime(27529): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653)
04-09 20:36:05.469: E/AndroidRuntime(27529): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678)
04-09 20:36:05.469: E/AndroidRuntime(27529): at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
04-09 20:36:05.469: E/AndroidRuntime(27529): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
04-09 20:36:05.469: E/AndroidRuntime(27529): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
04-09 20:36:05.469: E/AndroidRuntime(27529): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
04-09 20:36:05.469: E/AndroidRuntime(27529): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
04-09 20:36:05.469: E/AndroidRuntime(27529): at android.app.Activity.setContentView(Activity.java:1835)
04-09 20:36:05.469: E/AndroidRuntime(27529): at com.behram.mindmapmaker.SplashScreen.onCreate(SplashScreen.java:18)
04-09 20:36:05.469: E/AndroidRuntime(27529): at android.app.Activity.performCreate(Activity.java:4465)
04-09 20:36:05.469: E/AndroidRuntime(27529): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1051)
04-09 20:36:05.469: E/AndroidRuntime(27529): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
04-09 20:36:05.469: E/AndroidRuntime(27529): ... 11 more
04-09 20:36:05.469: E/AndroidRuntime(27529): Caused by: java.lang.reflect.InvocationTargetException
04-09 20:36:05.469: E/AndroidRuntime(27529): at java.lang.reflect.Constructor.constructNative(Native Method)
04-09 20:36:05.469: E/AndroidRuntime(27529): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
04-09 20:36:05.469: E/AndroidRuntime(27529): at android.view.LayoutInflater.createView(LayoutInflater.java:586)
04-09 20:36:05.469: E/AndroidRuntime(27529): ... 24 more
04-09 20:36:05.469: E/AndroidRuntime(27529): Caused by: java.lang.OutOfMemoryError
04-09 20:36:05.469: E/AndroidRuntime(27529): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
04-09 20:36:05.469: E/AndroidRuntime(27529): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:483)
04-09 20:36:05.469: E/AndroidRuntime(27529): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:351)
04-09 20:36:05.469: E/AndroidRuntime(27529): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:773)
04-09 20:36:05.469: E/AndroidRuntime(27529): at android.content.res.Resources.loadDrawable(Resources.java:1935)
04-09 20:36:05.469: E/AndroidRuntime(27529): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
04-09 20:36:05.469: E/AndroidRuntime(27529): at android.widget.ImageView.<init>(ImageView.java:119)
04-09 20:36:05.469: E/AndroidRuntime(27529): at android.widget.ImageView.<init>(ImageView.java:109)
04-09 20:36:05.469: E/AndroidRuntime(27529): ... 27 more
splash_screen.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/splash" />
</LinearLayout>
闪屏.java
public class SplashScreen extends Activity {
// Splash screen timer
private static int SPLASH_TIME_OUT = 3000;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash_screen);
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, ActivityB.class);
startActivity(i);
// close this activity
finish();
}
}, SPLASH_TIME_OUT);
}
}