When I try to add more than 4 images to the layout, the app crashes

I am making a simple table layout and displaying two images per row. When I add four images that fits in a single screen than its working correct but when I add more rows and other images the app crashes and says the app has stopped working. I have yet not started touching the mainActivity.class file. Just making a layout is giving me this error!

Here is the xml code:

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">


    <TableLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true">

        <TableRow>
            <ImageView
                android:layout_width="150dp"
                android:layout_height="200dp"
                android:id="@+id/imageView1"
                android:layout_row="0"
                android:layout_column="0"
                android:src="@drawable/img1"/>

            <ImageView
                android:layout_width="150dp"
                android:layout_height="200dp"
                android:id="@+id/imageView2"
                android:layout_row="0"
                android:layout_column="1"
                android:src="@drawable/img2"/>
        </TableRow>
        <TableRow>
            <ImageView
                android:layout_width="150dp"
                android:layout_height="200dp"
                android:id="@+id/imageView3"
                android:layout_row="1"
                android:layout_column="0"
                android:src="@drawable/img3"/>

            <ImageView
                android:layout_width="150dp"
                android:layout_height="200dp"
                android:id="@+id/imageView4"
                android:layout_row="1"
                android:layout_column="1"
                android:src="@drawable/img4"/>
        </TableRow>
        <TableRow>
            <ImageView
                android:layout_width="150dp"
                android:layout_height="200dp"
                android:id="@+id/imageView5"
                android:layout_row="2"
                android:layout_column="0"
                android:src="@drawable/img5"/>

            <ImageView
                android:layout_width="150dp"
                android:layout_height="200dp"
                android:id="@+id/imageView6"
                android:layout_row="2"
                android:layout_column="1"
                android:src="@drawable/img6"/>
        </TableRow>
        <TableRow>
            <ImageView
                android:layout_width="150dp"
                android:layout_height="200dp"
                android:id="@+id/imageView7"
                android:layout_row="3"
                android:layout_column="0"
                android:src="@drawable/img7"/>

            <ImageView
                android:layout_width="150dp"
                android:layout_height="200dp"
                android:id="@+id/imageView8"
                android:layout_row="3"
                android:layout_column="1"
                android:src="@drawable/img8"/>
        </TableRow>
        <TableRow>
            <ImageView
                android:layout_width="150dp"
                android:layout_height="200dp"
                android:id="@+id/imageView9"
                android:layout_row="4"
                android:layout_column="0"
                android:src="@drawable/img9"/>

            <ImageView
                android:layout_width="150dp"
                android:layout_height="200dp"
                android:id="@+id/imageView10"
                android:layout_row="4"
                android:layout_column="1"
                android:src="@drawable/img10"/>
        </TableRow>

    </TableLayout>
</RelativeLayout>

error log:

> 06-21 13:42:16.190    1542-1551/android.process.acore E/StrictMode﹕ A
> resource was acquired at attached stack trace but never released. See
> java.io.Closeable for information on avoiding resource leaks.
>     java.lang.Throwable: Explicit termination method 'close' not called
>             at dalvik.system.CloseGuard.open(CloseGuard.java:184)
>             at android.os.ParcelFileDescriptor.<init>(ParcelFileDescriptor.java:180)
>             at android.os.ParcelFileDescriptor$1.createFromParcel(ParcelFileDescriptor.java:916)
>             at android.os.ParcelFileDescriptor$1.createFromParcel(ParcelFileDescriptor.java:906)
>             at android.app.IBackupAgent$Stub.onTransact(IBackupAgent.java:57)
>             at android.os.Binder.execTransact(Binder.java:446) 06-21 13:42:16.190    1542-1551/android.process.acore E/StrictMode﹕ A
> resource was acquired at attached stack trace but never released. See
> java.io.Closeable for information on avoiding resource leaks.
>     java.lang.Throwable: Explicit termination method 'close' not called
>             at dalvik.system.CloseGuard.open(CloseGuard.java:184)
>             at android.os.ParcelFileDescriptor.<init>(ParcelFileDescriptor.java:180)
>             at android.os.ParcelFileDescriptor$1.createFromParcel(ParcelFileDescriptor.java:916)
>             at android.os.ParcelFileDescriptor$1.createFromParcel(ParcelFileDescriptor.java:906)
>             at android.app.IBackupAgent$Stub.onTransact(IBackupAgent.java:64)
>             at android.os.Binder.execTransact(Binder.java:446) 06-21 13:42:16.190    1542-1551/android.process.acore E/StrictMode﹕ A
> resource was acquired at attached stack trace but never released. See
> java.io.Closeable for information on avoiding resource leaks.
>     java.lang.Throwable: Explicit termination method 'close' not called
>             at dalvik.system.CloseGuard.open(CloseGuard.java:184)
>             at android.os.ParcelFileDescriptor.<init>(ParcelFileDescriptor.java:180)
>             at android.os.ParcelFileDescriptor$1.createFromParcel(ParcelFileDescriptor.java:916)
>             at android.os.ParcelFileDescriptor$1.createFromParcel(ParcelFileDescriptor.java:906)
>             at android.app.IBackupAgent$Stub.onTransact(IBackupAgent.java:71)
>             at android.os.Binder.execTransact(Binder.java:446)


Source: xml

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.