StartActivity突然停止启动另一个活动

时间:2015-04-27 15:04:38

标签: java android

没有任何问题的startActivity突然崩溃了,我得到一条消息'不幸的是应用程序已停止工作'。我放了一个断点 一切顺利,直到它到达startActivity线。 startActivity不会进入' listviewtitles.class'一点都不我还在这个“listviewtitles.class”的开头加了一个断点。但调试器不会进入此类。在startActivity中,如果我更改了' listviewtitles.class'到另一个xyz.class它运作良好。与此同时,来自另一个班级' startActivity转到' listviewtitles.class'。看来问题只在于这两项活动。早些时候它没有任何问题。

   startActivity(new Intent( titles_new.this,listviewtitles.class));

在log cat中它就像:

04-27 20:22:22.338  15020-15020/com.example.rajendran.myapplication W/System.err﹕ at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:641)
04-27 20:22:22.338  15020-15020/com.example.rajendran.myapplication W/System.err﹕ at dalvik.system.NativeStart.main(Native Method)
04-27 20:22:22.338  15020-15020/com.example.rajendran.myapplication W/dalvikvm﹕ threadid=1: calling UncaughtExceptionHandler
04-27 20:22:22.342  15020-15020/com.example.rajendran.myapplication E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.example.rajendran.myapplication, PID: 15020
    java.lang.ArrayIndexOutOfBoundsException: length=1; index=1
            at android.widget.SimpleCursorAdapter.bindView(SimpleCursorAdapter.java:150)
            at android.widget.CursorAdapter.getView(CursorAdapter.java:254)
            at android.widget.AbsListView.obtainView(AbsListView.java:2338)
            at android.widget.ListView.makeAndAddView(ListView.java:1813)
            at android.widget.ListView.fillDown(ListView.java:698)
            at android.widget.ListView.fillFromTop(ListView.java:759)
            at android.widget.ListView.layoutChildren(ListView.java:1646)
            at android.widget.AbsListView.onLayout(AbsListView.java:2149)
            at android.view.View.layout(View.java:15140)
            at android.view.ViewGroup.layout(ViewGroup.java:4867)
            at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1160)
            at android.view.View.layout(View.java:15140)
            at android.view.ViewGroup.layout(ViewGroup.java:4867)
            at android.widget.FrameLayout.layoutChildren(FrameLayout.java:515)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:450)
            at android.view.View.layout(View.java:15140)
            at android.view.ViewGroup.layout(ViewGroup.java:4867)
            at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1888)
            at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1742)
            at android.widget.LinearLayout.onLayout(LinearLayout.java:1651)
            at android.view.View.layout(View.java:15140)
            at android.view.ViewGroup.layout(ViewGroup.java:4867)
            at android.widget.FrameLayout.layoutChildren(FrameLayout.java:515)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:450)
            at android.view.View.layout(View.java:15140)
            at android.view.ViewGroup.layout(ViewGroup.java:4867)
            at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2480)
            at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2175)
            at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1249)
            at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6420)
            at android.view.Choreographer$CallbackRecord.run(Choreographer.java:788)
            at android.view.Choreographer.doCallbacks(Choreographer.java:591)
            at android.view.Choreographer.doFrame(Choreographer.java:560)
            at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:774)
            at android.os.Handler.handleCallback(Handler.java:808)
            at android.os.Handler.dispatchMessage(Handler.java:103)
            at android.os.Looper.loop(Looper.java:193)
            at android.app.ActivityThread.main(ActivityThread.java:5299)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:825)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:641)
            at dalvik.system.NativeStart.main(Native Method)

1 个答案:

答案 0 :(得分:1)

看起来你的SimpleCursorAdapter试图访问和数组,并且索引不会退出;

java.lang.ArrayIndexOutOfBoundsException: length=1; index=1