当我从片段5滑动到6时,它给了我一个错误

时间:2018-03-10 13:09:32

标签: android android-fragments

当我从片段5滑动到6时,虽然我在第1页到第5页上有很多图像,但它给了我一个错误,但为什么它给了我6个片段到onwawrds的错误。

这是错误

03-10 18:04:10.163 28242-28242/com.example.fahad.qaida E/AndroidRuntime: FATAL EXCEPTION: main
                                                                     Process: com.example.fahad.qaida, PID: 28242
                                                                     android.view.InflateException: Binary XML file line #0: Error inflating class <unknown>
                                                                         at android.view.LayoutInflater.createView(LayoutInflater.java:640)
                                                                         at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
                                                                         at android.view.LayoutInflater.onCreateView(LayoutInflater.java:689)
                                                                         at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:748)
                                                                         at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
                                                                         at android.view.LayoutInflater.rInflate(LayoutInflater.java:821)
                                                                         at android.view.LayoutInflater.inflate(LayoutInflater.java:511)
                                                                         at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
                                                                         at com.example.fahad.qaida.Page7.onCreateView(Page7.java:15)
                                                                         at android.support.v4.app.Fragment.performCreateView(Fragment.java:2354)
                                                                         at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1419)
                                                                         at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1740)
                                                                         at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1809)
                                                                         at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:799)
                                                                         at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2580)
                                                                         at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2367)
                                                                         at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2322)
                                                                         at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:2199)
                                                                         at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:651)
                                                                         at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:145)
                                                                         at android.support.v4.view.ViewPager.populate(ViewPager.java:1236)
                                                                         at android.support.v4.view.ViewPager.populate(ViewPager.java:1084)
                                                                         at android.support.v4.view.ViewPager$3.run(ViewPager.java:267)
                                                                         at android.view.Choreographer$CallbackRecord.run(Choreographer.java:777)
                                                                         at android.view.Choreographer.doCallbacks(Choreographer.java:590)
                                                                         at android.view.Choreographer.doFrame(Choreographer.java:559)
                                                                         at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:763)
                                                                         at android.os.Handler.handleCallback(Handler.java:739)
                                                                         at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                         at android.os.Looper.loop(Looper.java:145)
                                                                         at android.app.ActivityThread.main(ActivityThread.java:5938)
                                                                         at java.lang.reflect.Method.invoke(Native Method)
                                                                         at java.lang.reflect.Method.invoke(Method.java:372)
                                                                         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
                                                                         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
                                                                      Caused by: java.lang.reflect.InvocationTargetException
                                                                         at java.lang.reflect.Constructor.newInstance(Native Method)
                                                                         at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
                                                                         at android.view.LayoutInflater.createView(LayoutInflater.java:614)
                                                                         at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55) 
                                                                         at android.view.LayoutInflater.onCreateView(LayoutInflater.java:689) 
                                                                         at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:748) 
                                                                         at android.view.LayoutInflater.rInflate(LayoutInflater.java:813) 
                                                                         at android.view.LayoutInflater.rInflate(LayoutInflater.java:821) 
                                                                         at android.view.LayoutInflater.inflate(LayoutInflater.java:511) 
                                                                         at android.view.LayoutInflater.inflate(LayoutInflater.java:415) 
                                                                         at com.example.fahad.qaida.Page7.onCreateView(Page7.java:15) 
                                                                         at android.support.v4.app.Fragment.performCreateView(Fragment.java:2354) 
                                                                         at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1419) 
                                                                         at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1740) 
                                                                         at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1809) 
                                                                         at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:799) 
                                                                         at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2580) 
                                                                         at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2367) 
                                                                         at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2322) 
                                                                         at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:2199) 
                                                                         at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:651) 
                                                                         at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:145) 
                                                                         at android.support.v4.view.ViewPager.populate(ViewPager.java:1236) 
                                                                         at android.support.v4.view.ViewPager.populate(ViewPager.java:1084) 
                                                                         at android.support.v4.view.ViewPager$3.run(ViewPager.java:267) 
                                                                         at android.view.Choreographer$CallbackRecord.run(Choreographer.java:777) 
                                                                         at android.view.Choreographer.doCallbacks(Choreographer.java:590) 
                                                                         at android.view.Choreographer.doFrame(Choreographer.java:559) 
                                                                         at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:763) 
                                                                         at android.os.Handler.handleCallback(Handler.java:739) 
                                                                         at android.os.Handler.dispatchMessage(Handler.java:95) 
                                                                         at android.os.Looper.loop(Looper.java:145) 
                                                                         at android.app.ActivityThread.main(ActivityThread.java:5938) 
                                                                         at java.lang.reflect.Method.invoke(Native Method) 
                                                                         at java.lang.reflect.Method.invoke(Method.java:372) 
                                                                         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400) 
                                                                         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195) 
                                                                      Caused by: java.lang.OutOfMemoryError: Failed to allocate a 1102512 byte allocation with 736876 free bytes and 719KB until OOM
                                                                         at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
                                                                         at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
                                                                         at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:745)
                                                                         at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:566)
                                                                         at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:1014)
                                                                         at android.content.res.Resources.loadDrawableForCookie(Resources.java:3730)
                                                                         at android.content.res.Resources.loadDrawable(Resources.java:3603)
                                                                         at android.content.res.TypedArray.getDrawable(TypedArray.java:762)
                                                                         at android.view.View.<init>(View.java:3957)
                                                                         at android.widget.ImageView.<init>(ImageView.java:144)
                                                                         at android.widget.ImageView.<init>(ImageView.java:140)
                                                                         at android.widget.ImageView.<init>(ImageView.java:136)
                                                                         at java.lang.reflect.Constructor.newInstance(Native Method) 
                                                                         at java.lang.reflect.Constructor.newInstance(Constructor.java:288) 
                                                                         at android.view.LayoutInflater.createView(LayoutInflater.java:614) 
                                                                         at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55) 
                                                                         at android.view.LayoutInflater.onCreateView(LayoutInflater.java:689) 
                                                                         at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:748) 
                                                                         at android.view.LayoutInflater.rInflate(LayoutInflater.java:813) 
                                                                         at android.view.LayoutInflater.rInflate(LayoutInflater.java:821) 
                                                                         at android.view.LayoutInflater.inflate(LayoutInflater.java:511) 
                                                                         at android.view.LayoutInflater.inflate(LayoutInflater.java:415) 
                                                                         at com.example.fahad.qaida.Page7.onCreateView(Page7.java:15) 
                                                                         at android.support.v4.app.Fragment.performCreateView(Fragment.java:2354) 
                                                                         at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1419) 
                                                                         at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1740) 
                                                                         at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1809) 
                                                                         at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:799) 
                                                                         at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2580) 
                                                                         at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2367) 
                                                                         at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2322) 
                                                                         at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:2199) 
                                                                         at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:651) 
                                                                         at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:145) 
                                                                         at android.support.v4.view.ViewPager.populate(ViewPager.java:1236) 
                                                                         at android.support.v4.view.ViewPager.populate(ViewPager.java:1084) 
                                                                         at android.support.v4.view.ViewPager$3.run(ViewPager.java:267) 
                                                                         at android.view.Choreographer$CallbackRecord.run(Choreographer.java:777) 
                                                                         at android.view.Choreographer.doCallbacks(Choreographer.java:590) 
                                                                         at android.view.Choreographer.doFrame(Choreographer.java:559) 
                                                                         at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:763) 
                                                                         at android.os.Handler.handleCallback(Handler.java:739) 
                                                                         at android.os.Handler.dispatchMessage(Handler.java:95) 
                                                                         at android.os.Looper.loop(Looper.java:145) 
                                                                         at android.app.ActivityThread.main(ActivityThread.java:5938) 
                                                                         at java.lang.reflect.Method.invoke(Native Method) 
                                                                         at java.lang.reflect.Method.invoke(Method.java:372) 
                                                                         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400) 
                                                                         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195) 

我的第6页java是

public class Page6 extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    return inflater.inflate(R.layout.fragment_page6, container, false);
}

}

这是我的第6页xml

 <ImageButton
    android:id="@+id/book"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:src="@drawable/book"
    android:background="@android:color/transparent"

    />




<RelativeLayout
    android:id="@+id/r6"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="20dp"
    android:layout_marginRight="20dp"
    android:layout_marginTop="35dp"
    android:gravity="center"
    >


    <ImageView
        android:id="@+id/pg6_1"
        android:layout_width="wrap_content"
        android:layout_height="50dp"
        android:src="@drawable/pg6_1"
        android:layout_alignParentRight="true"
        />

    <ImageView
        android:id="@+id/pg6_2"
        android:layout_width="wrap_content"
        android:layout_height="50dp"
        android:src="@drawable/pg6_2"
        android:layout_below="@id/pg6_1"
        />

</RelativeLayout>

<RelativeLayout
    android:id="@+id/r6_1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/r6"
    android:layout_marginLeft="20dp"
    android:layout_marginRight="20dp"
    android:gravity="center"

    >

    <ImageView
        android:id="@+id/pg6_3"
        android:layout_width="75dp"
        android:layout_height="52dp"
        android:src="@drawable/pg6_3"
        android:layout_alignParentRight="true"
        />

    <ImageView
        android:id="@+id/pg6_4"
        android:layout_width="75dp"
        android:layout_height="52dp"
        android:src="@drawable/pg6_4"
        android:layout_toLeftOf="@id/pg6_3"

        />



</RelativeLayout>

我在非常低的kbs的每个片段上都有相同的图像,例如页面号。 6所有图像均为8kb,而其他1至5的图像具有30或40kbs的图像

第7页代码,下面是xml

java代码

public class Page7 extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    return inflater.inflate(R.layout.fragment_page7, container, false);
}

}

ml第7页

<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:background="@drawable/border7"
tools:context="com.example.fahad.qaida.Page7">

<ImageButton
    android:id="@+id/book"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:src="@drawable/book"
    android:background="@android:color/transparent"

    />

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginLeft="20dp"
    android:layout_marginRight="20dp"
    android:layout_marginBottom="20dp"
    android:layout_marginTop="30dp"
    android:gravity="center"
    >


    <ImageView
        android:id="@+id/pg7_1"
        android:layout_width="53dp"
        android:layout_height="50dp"
        android:src="@drawable/pg7_1"
        android:layout_alignParentRight="true"
        />

    <ImageView
        android:id="@+id/pg7_2"
        android:layout_width="53dp"
        android:layout_height="51dp"
        android:src="@drawable/pg7_2"
        android:layout_toLeftOf="@id/pg7_1"
        />

    <ImageView
        android:id="@+id/pg7_3"
        android:layout_width="53dp"
        android:layout_height="51dp"
        android:src="@drawable/pg7_3"
        android:layout_toLeftOf="@id/pg7_2"

        />

    <ImageView
        android:id="@+id/pg7_4"
        android:layout_width="53dp"
        android:layout_height="51dp"
        android:src="@drawable/pg7_4"
        android:layout_toLeftOf="@id/pg7_3"

        />

    <ImageView
        android:id="@+id/pg7_5"
        android:layout_width="53dp"
        android:layout_height="51dp"
        android:src="@drawable/pg7_5"
        android:layout_toLeftOf="@id/pg7_4"
        />

    <ImageView
        android:id="@+id/pg7_6"
        android:layout_width="53dp"
        android:layout_height="51dp"
        android:src="@drawable/pg7_6"
        android:layout_toLeftOf="@id/pg7_5"
        />


    <ImageView
        android:id="@+id/pg7_7"
        android:layout_width="53dp"
        android:layout_height="51dp"
        android:src="@drawable/pg7_7"
        android:layout_alignParentRight="true"
        android:layout_below="@id/pg7_1"
        />

    <ImageView
        android:id="@+id/pg7_8"
        android:layout_width="53dp"
        android:layout_height="51dp"
        android:src="@drawable/pg7_8"
        android:layout_toLeftOf="@id/pg7_7"
        android:layout_below="@id/pg7_2"
        />

    <ImageView
        android:id="@+id/pg7_9"
        android:layout_width="53dp"
        android:layout_height="51dp"
        android:src="@drawable/pg7_9"
        android:layout_toLeftOf="@id/pg7_8"
        android:layout_below="@id/pg7_3"

        />

    <ImageView
        android:id="@+id/pg7_10"
        android:layout_width="53dp"
        android:layout_height="51dp"
        android:src="@drawable/pg7_10"
        android:layout_toLeftOf="@id/pg7_9"
        android:layout_below="@id/pg7_4"

        />

    </RelativeLayout>

0 个答案:

没有答案