2

我已经为 curlview 的页面动画制作了一个活动,但是当我尝试为我的第二页制作活动的副本时,当我运行代码时出现此错误,这是 logcat 消息:

03-02 03:42:10.385: E/AndroidRuntime(1821): FATAL EXCEPTION: main
03-02 03:42:10.385: E/AndroidRuntime(1821): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.lspu.handbook/com.lspu.handbook.Hand_Book_mission}: android.view.InflateException: Binary XML file line #7: Error inflating class com.lspu.handbook.lspu_book_adapter_mission
03-02 03:42:10.385: E/AndroidRuntime(1821):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
03-02 03:42:10.385: E/AndroidRuntime(1821):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
03-02 03:42:10.385: E/AndroidRuntime(1821):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
03-02 03:42:10.385: E/AndroidRuntime(1821):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
03-02 03:42:10.385: E/AndroidRuntime(1821):     at android.os.Handler.dispatchMessage(Handler.java:99)
03-02 03:42:10.385: E/AndroidRuntime(1821):     at android.os.Looper.loop(Looper.java:137)
03-02 03:42:10.385: E/AndroidRuntime(1821):     at android.app.ActivityThread.main(ActivityThread.java:5039)
03-02 03:42:10.385: E/AndroidRuntime(1821):     at java.lang.reflect.Method.invokeNative(Native Method)
03-02 03:42:10.385: E/AndroidRuntime(1821):     at java.lang.reflect.Method.invoke(Method.java:511)
03-02 03:42:10.385: E/AndroidRuntime(1821):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
03-02 03:42:10.385: E/AndroidRuntime(1821):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
03-02 03:42:10.385: E/AndroidRuntime(1821):     at dalvik.system.NativeStart.main(Native Method)
03-02 03:42:10.385: E/AndroidRuntime(1821): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class com.lspu.handbook.lspu_book_adapter_mission
03-02 03:42:10.385: E/AndroidRuntime(1821):     at android.view.LayoutInflater.createView(LayoutInflater.java:613)
03-02 03:42:10.385: E/AndroidRuntime(1821):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
03-02 03:42:10.385: E/AndroidRuntime(1821):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
03-02 03:42:10.385: E/AndroidRuntime(1821):     at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
03-02 03:42:10.385: E/AndroidRuntime(1821):     at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
03-02 03:42:10.385: E/AndroidRuntime(1821):     at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
03-02 03:42:10.385: E/AndroidRuntime(1821):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
03-02 03:42:10.385: E/AndroidRuntime(1821):     at android.app.Activity.setContentView(Activity.java:1881)
03-02 03:42:10.385: E/AndroidRuntime(1821):     at com.lspu.handbook.Hand_Book_mission.onCreate(Hand_Book_mission.java:23)
03-02 03:42:10.385: E/AndroidRuntime(1821):     at android.app.Activity.performCreate(Activity.java:5104)
03-02 03:42:10.385: E/AndroidRuntime(1821):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
03-02 03:42:10.385: E/AndroidRuntime(1821):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
03-02 03:42:10.385: E/AndroidRuntime(1821):     ... 11 more
03-02 03:42:10.385: E/AndroidRuntime(1821): Caused by: java.lang.reflect.InvocationTargetException
03-02 03:42:10.385: E/AndroidRuntime(1821):     at java.lang.reflect.Constructor.constructNative(Native Method)
03-02 03:42:10.385: E/AndroidRuntime(1821):     at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
03-02 03:42:10.385: E/AndroidRuntime(1821):     at android.view.LayoutInflater.createView(LayoutInflater.java:587)
03-02 03:42:10.385: E/AndroidRuntime(1821):     ... 22 more
03-02 03:42:10.385: E/AndroidRuntime(1821): Caused by: java.lang.IndexOutOfBoundsException: Invalid index 1, size is 1
03-02 03:42:10.385: E/AndroidRuntime(1821):     at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:251)
03-02 03:42:10.385: E/AndroidRuntime(1821):     at java.util.ArrayList.get(ArrayList.java:304)
03-02 03:42:10.385: E/AndroidRuntime(1821):     at com.lspu.handbook.lspu_book_adapter_mission.init(lspu_book_adapter_mission.java:313)
03-02 03:42:10.385: E/AndroidRuntime(1821):     at com.lspu.handbook.lspu_book_adapter_mission.<init>(lspu_book_adapter_mission.java:233)
03-02 03:42:10.385: E/AndroidRuntime(1821):     ... 25 more

这是我的 xml 代码,logcat 说有错误:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <com.lspu.handbook.lspu_book_adapter_mission
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:id="@+id/dcgpagecurlPageCurlView1"
        android:background="@drawable/lspuhdpg1">

    </com.lspu.handbook.lspu_book_adapter_mission>


</LinearLayout>

有人知道这里有什么问题吗?

谢谢。

4

1 回答 1

5
 Caused by: java.lang.IndexOutOfBoundsException: Invalid index 1, size is 1
03-02 03:42:10.385: E/AndroidRuntime(1821):     at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:251)
03-02 03:42:10.385: E/AndroidRuntime(1821):     at java.util.ArrayList.get(ArrayList.java:304)

问题不在给定的代码中。它在lspu_book_adapter_mission检查您的 AArrayList 中。因为它抛出一个IndexOutOfBoundsException

于 2013-03-02T03:51:00.903 回答