gpt4 book ai didi

java - StartActivity 突然停止启动另一个 Activity

转载 作者:行者123 更新时间:2023-12-01 11:36:43 25 4
gpt4 key购买 nike

原本运行良好、没有任何问题的 startActivity 突然崩溃了,我收到一条消息“不幸的是应用程序已停止工作”。我设置了一个断点并检查了一切,一切顺利,直到到达 startActivity 行。startActivity 根本不会进入“listviewtitles.class”。我还在“listviewtitles.class”的开头放置了一个断点,但调试器不会进入该类。在 startActivity 中,如果我将“listviewtitles.class”更改为另一个 xyz.class,则效果很好。同时,startActivity 从“另一个类”转到“listviewtitles.class”。看来问题只存在于这两项 Activity 之间。早些时候一切顺利,没有任何问题。

   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)

最佳答案

看起来您的 SimpleCursorAdapter 正在尝试访问数组,并且索引不存在;

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

关于java - StartActivity 突然停止启动另一个 Activity,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29899328/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com