0

レイアウト部分のみ修正します。エラーが発生するのはなぜですか?

<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
4

3 に答える 3

0

レイアウト ファイルでは、最初の行の<?xml version="1.0" encoding="utf-8"?>一部が欠落しています。その行は実際のファイルにありますか?

于 2013-05-24T17:40:09.480 に答える
0

一見、layout_weight属性が不要に見えます。彼らはsでしか働かないと思いますLinearLayout

于 2013-05-24T17:26:34.033 に答える
0

巨大なサイズの画像を使用しているようです。画像リソースを確認してください

于 2013-05-24T17:18:43.977 に答える