“无法开始活动”错误

发布于 2024-11-04 00:20:14 字数 5248 浏览 0 评论 0原文

我的代码:

private void filldata(){
    Cursor datacursor = sqlite.fetchalldata("Program");
    startManagingCursor(datacursor);

    String[] from = new String[]{DatabaseHelper.KEY_PROGRAM_DATE, DatabaseHelper.KEY_PROGRAM_TIME, DatabaseHelper.KEY_PROGRAM_CHANNEL};
    String[] from1 = new String[]{DatabaseHelper.KEY_PROGRAM_TITLE};

    int[] to = new int[]{R.id.programdate, R.id.programtime, R.id.programchannel};
    int[] to1 = new int[]{R.id.programtitle};

    SimpleExpandableListAdapter SEL = new SimpleExpandableListAdapter(this, 
                    createGroupList(), R.layout.programgroup_row, from1, to1,       
                    createChildList(), R.layout.programchild_row, from, to);
    setListAdapter( SEL );
}

当我在 oncreate() 中调用 filldata() 时,Logcat 给了我这个错误:

04-27 03:43:10.066: WARN/dalvikvm(279): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
04-27 03:43:10.146: ERROR/AndroidRuntime(279): FATAL EXCEPTION: main
04-27 03:43:10.146: ERROR/AndroidRuntime(279): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.imammuda/com.android.imammuda.ImamMuda}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.imammuda/com.android.imammuda.Program}: java.lang.NullPointerException
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.os.Looper.loop(Looper.java:123)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.app.ActivityThread.main(ActivityThread.java:4627)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at java.lang.reflect.Method.invokeNative(Native Method)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at java.lang.reflect.Method.invoke(Method.java:521)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at dalvik.system.NativeStart.main(Native Method)
04-27 03:43:10.146: ERROR/AndroidRuntime(279): Caused by: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.imammuda/com.android.imammuda.Program}: java.lang.NullPointerException
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.app.ActivityThread.startActivityNow(ActivityThread.java:2503)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:127)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:339)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:651)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.widget.TabHost.setCurrentTab(TabHost.java:323)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.widget.TabHost.addTab(TabHost.java:213)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at com.android.imammuda.ImamMuda.onCreate(ImamMuda.java:26)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     ... 11 more
04-27 03:43:10.146: ERROR/AndroidRuntime(279): Caused by: java.lang.NullPointerException
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at com.android.imammuda.Program.createGroupList(Program.java:91)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at com.android.imammuda.Program.filldata(Program.java:45)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at com.android.imammuda.Program.onCreate(Program.java:29)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     ... 20 more

*其他类

Databasehelper extends SqliteOpenHelper

sqlite 从/到 获取了 openclosecreatedatafetchdata databasehelper

我想知道为什么当我调用该函数时会出现此错误,而当我不调用它时却没有问题。

My code:

private void filldata(){
    Cursor datacursor = sqlite.fetchalldata("Program");
    startManagingCursor(datacursor);

    String[] from = new String[]{DatabaseHelper.KEY_PROGRAM_DATE, DatabaseHelper.KEY_PROGRAM_TIME, DatabaseHelper.KEY_PROGRAM_CHANNEL};
    String[] from1 = new String[]{DatabaseHelper.KEY_PROGRAM_TITLE};

    int[] to = new int[]{R.id.programdate, R.id.programtime, R.id.programchannel};
    int[] to1 = new int[]{R.id.programtitle};

    SimpleExpandableListAdapter SEL = new SimpleExpandableListAdapter(this, 
                    createGroupList(), R.layout.programgroup_row, from1, to1,       
                    createChildList(), R.layout.programchild_row, from, to);
    setListAdapter( SEL );
}

when I call filldata() in oncreate(), the Logcat gave me this error:

04-27 03:43:10.066: WARN/dalvikvm(279): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
04-27 03:43:10.146: ERROR/AndroidRuntime(279): FATAL EXCEPTION: main
04-27 03:43:10.146: ERROR/AndroidRuntime(279): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.imammuda/com.android.imammuda.ImamMuda}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.imammuda/com.android.imammuda.Program}: java.lang.NullPointerException
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.os.Looper.loop(Looper.java:123)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.app.ActivityThread.main(ActivityThread.java:4627)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at java.lang.reflect.Method.invokeNative(Native Method)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at java.lang.reflect.Method.invoke(Method.java:521)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at dalvik.system.NativeStart.main(Native Method)
04-27 03:43:10.146: ERROR/AndroidRuntime(279): Caused by: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.imammuda/com.android.imammuda.Program}: java.lang.NullPointerException
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.app.ActivityThread.startActivityNow(ActivityThread.java:2503)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:127)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:339)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:651)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.widget.TabHost.setCurrentTab(TabHost.java:323)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.widget.TabHost.addTab(TabHost.java:213)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at com.android.imammuda.ImamMuda.onCreate(ImamMuda.java:26)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     ... 11 more
04-27 03:43:10.146: ERROR/AndroidRuntime(279): Caused by: java.lang.NullPointerException
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at com.android.imammuda.Program.createGroupList(Program.java:91)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at com.android.imammuda.Program.filldata(Program.java:45)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at com.android.imammuda.Program.onCreate(Program.java:29)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     ... 20 more

*Other classes

Databasehelper extends SqliteOpenHelper

sqlite which got open, close, createdata, fetchdata from/to the databasehelper

I want to know why I get this error when I the function and no issues when I do not call it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

待"谢繁草 2024-11-11 00:20:14

它在 Program 类第 91 行中遇到了 NullPointer Exception。检查该行并尝试解决此空指针异常

Its hitting a NullPointer Exception in the Program class line number 91. Check that line and try to resolve this null pointer exception

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文