无法启动活动ComponentInfo?怎么了?

时间:2013-05-24 17:17:13

标签: android

我只修改布局部分。为什么我有错误?

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/myTableLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#000000"
    android:orientation="vertical" >

    <TableRow>

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="200dp"
            android:layout_margin="1dp"
            android:src="@drawable/aa2" />
    </TableRow>

    <TableRow>

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="150dp"
            android:layout_margin="2dp"
            android:layout_weight="1"
            android:src="@drawable/a8" />

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="150dp"
            android:layout_margin="2dp"
            android:layout_weight="1"
            android:src="@drawable/a4"
            android:text="" />
    </TableRow>

    <TableRow>

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="150dp"
            android:layout_margin="2dp"
            android:layout_weight="1"
            android:src="@drawable/a7"
            android:text="" />

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="150dp"
            android:layout_margin="2dp"
            android:layout_weight="2"
            android:src="@drawable/a6"
            android:text="" />
    </TableRow>

</TableLayout>

错误讯息:

05-24 16:58:14.170: E/AndroidRuntime(801): FATAL EXCEPTION: main

05-24 16:58:14.170: E/AndroidRuntime(801): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example/com.example.MainActivity}: android.view.InflateException: Binary XML file line #23: Error inflating class <unknown>

05-24 16:58:14.170: E/AndroidRuntime(801):at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)

05-24 16:58:14.170: E/AndroidRuntime(801):at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)

05-24 16:58:14.170: E/AndroidRuntime(801):at android.app.ActivityThread.access$600(ActivityThread.java:141)

05-24 16:58:14.170: E/AndroidRuntime(801):at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)

05-24 16:58:14.170: E/AndroidRuntime(801):at android.os.Handler.dispatchMessage(Handler.java:99)

05-24 16:58:14.170: E/AndroidRuntime(801):at android.os.Looper.loop(Looper.java:137)

05-24 16:58:14.170: E/AndroidRuntime(801):at android.app.ActivityThread.mai(ActivityThread.java:5041)

05-24 16:58:14.170: E/AndroidRuntime(801):at java.lang.reflect.Method.invokeNative(Native Method)

05-24 16:58:14.170: E/AndroidRuntime(801):at java.lang.reflect.Method.invoke(Method.java:511)

05-24 16:58:14.170: E/AndroidRuntime(801):at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)

05-24 16:58:14.170: E/AndroidRuntime(801):at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)

05-24 16:58:14.170: E/AndroidRuntime(801):at dalvik.system.NativeStart.main(Native Method)

05-24 16:58:14.170: E/AndroidRuntime(801): Caused by: android.view.InflateException: Binary XML file line #23: Error inflating class <unknown>

05-24 16:58:14.170: E/AndroidRuntime(801):at android.view.LayoutInflater.createView(LayoutInflater.java:613)

05-24 16:58:14.170: E/AndroidRuntime(801):at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)

05-24 16:58:14.170: E/AndroidRuntime(801):at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)

05-24 16:58:14.170: E/AndroidRuntime(801):at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)

05-24 16:58:14.170: E/AndroidRuntime(801):at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)

05-24 16:58:14.170: E/AndroidRuntime(801):at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)

05-24 16:58:14.170: E/AndroidRuntime(801):at android.view.LayoutInflater.inflate(LayoutInflater.java:489)

05-24 16:58:14.170: E/AndroidRuntime(801):at android.view.LayoutInflater.inflate(LayoutInflater.java:396)

05-24 16:58:14.170: E/AndroidRuntime(801): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)

05-24 16:58:14.170: E/AndroidRuntime(801):at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)

05-24 16:58:14.170: E/AndroidRuntime(801):at android.app.Activity.setContentView(Activity.java:1881)

05-24 16:58:14.170: E/AndroidRuntime(801):at com.example.MainActivity.onCreate(MainActivity.java:14)

05-24 16:58:14.170: E/AndroidRuntime(801):at android.app.Activity.performCreate(Activity.java:5104)

05-24 16:58:14.170: E/AndroidRuntime(801):at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)

05-24 16:58:14.170: E/AndroidRuntime(801):at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)

05-24 16:58:14.170: E/AndroidRuntime(801):... 11 more

05-24 16:58:14.170: E/AndroidRuntime(801):Caused by: java.lang.reflect.InvocationTargetException

05-24 16:58:14.170: E/AndroidRuntime(801):at java.lang.reflect.Constructor.constructNative(Native Method)

05-24 16:58:14.170: E/AndroidRuntime(801):at java.lang.reflect.Constructor.newInstance(Constructor.java:417)

05-24 16:58:14.170: E/AndroidRuntime(801):at android.view.LayoutInflater.createView(LayoutInflater.java:587)

05-24 16:58:14.170: E/AndroidRuntime(801): ... 25 more

05-24 16:58:14.170: E/AndroidRuntime(801): Caused by: java.lang.OutOfMemoryError

05-24 16:58:14.170: E/AndroidRuntime(801): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)

05-24 16:58:14.170: E/AndroidRuntime(801):at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:502)

05-24 16:58:14.170: E/AndroidRuntime(801):at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:355)

05-24 16:58:14.170: E/AndroidRuntime(801):at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:785)

05-24 16:58:14.170: E/AndroidRuntime(801):at android.content.res.Resources.loadDrawable(Resources.java:1965)

05-24 16:58:14.170: E/AndroidRuntime(801):at android.content.res.TypedArray.getDrawable(TypedArray.java:601)

05-24 16:58:14.170: E/AndroidRuntime(801):at android.widget.ImageView.<init>(ImageView.java:120)

05-24 16:58:14.170: E/AndroidRuntime(801):at android.widget.ImageView.<init>(ImageView.java:110)

05-24 16:58:14.170: E/AndroidRuntime(801): ... 28 more

3 个答案:

答案 0 :(得分:0)

您似乎正在使用巨大尺寸的图像。检查您的图像资源

答案 1 :(得分:0)

简而言之,似乎layout_weight属性是不必要的。我认为他们只能使用LinearLayout s。

答案 2 :(得分:0)

在布局文件中,作为第一行,您错过了<?xml version="1.0" encoding="utf-8"?>部分。是你实际档案中的那一行吗?