致命异常:main



我遇到了一点小麻烦。我对此完全陌生。我正试图让我的应用程序从一个启动屏幕开始,然后继续进行一个新的活动,但我的应用一直在强制关闭,只有一个致命的例外:main。这是logcat

02-12 02:56:32.989: D/AndroidRuntime(1487): Shutting down VM
02-12 02:56:32.989: W/dalvikvm(1487): threadid=1: thread exiting with uncaught exception (group=0x4001e560)
02-12 02:56:33.009: E/AndroidRuntime(1487): FATAL EXCEPTION: main
02-12 02:56:33.009: E/AndroidRuntime(1487): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.madonk.LAFEST/com.madonk.LAFEST.MAIN}: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
02-12 02:56:33.009: E/AndroidRuntime(1487):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1702)
02-12 02:56:33.009: E/AndroidRuntime(1487):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1722)
02-12 02:56:33.009: E/AndroidRuntime(1487):     at android.app.ActivityThread.access$1500(ActivityThread.java:124)
02-12 02:56:33.009: E/AndroidRuntime(1487):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:974)
02-12 02:56:33.009: E/AndroidRuntime(1487):     at android.os.Handler.dispatchMessage(Handler.java:99)
02-12 02:56:33.009: E/AndroidRuntime(1487):     at android.os.Looper.loop(Looper.java:130)
02-12 02:56:33.009: E/AndroidRuntime(1487):     at android.app.ActivityThread.main(ActivityThread.java:3821)
02-12 02:56:33.009: E/AndroidRuntime(1487):     at java.lang.reflect.Method.invokeNative(Native Method)
02-12 02:56:33.009: E/AndroidRuntime(1487):     at java.lang.reflect.Method.invoke(Method.java:507)
02-12 02:56:33.009: E/AndroidRuntime(1487):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
02-12 02:56:33.009: E/AndroidRuntime(1487):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
02-12 02:56:33.009: E/AndroidRuntime(1487):     at dalvik.system.NativeStart.main(Native Method)
02-12 02:56:33.009: E/AndroidRuntime(1487): Caused by: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
02-12 02:56:33.009: E/AndroidRuntime(1487):     at android.app.ListActivity.onContentChanged(ListActivity.java:243)
02-12 02:56:33.009: E/AndroidRuntime(1487):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
02-12 02:56:33.009: E/AndroidRuntime(1487):     at android.app.Activity.setContentView(Activity.java:1716)
02-12 02:56:33.009: E/AndroidRuntime(1487):     at com.madonk.LAFEST.MAIN.onCreate(MAIN.java:17)
02-12 02:56:33.009: E/AndroidRuntime(1487):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
02-12 02:56:33.009: E/AndroidRuntime(1487):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1666)
02-12 02:56:33.009: E/AndroidRuntime(1487):     ... 11 more

如果有人能帮忙,我将不胜感激。

您的活动可能扩展了ListActivity,因此在包含活动布局的xml文件中(使用setContentView(R.layout.name_of_layout设置的文件),您必须有一个id为的ListView元素

<ListView android:id="@android:id/list"
//other attributes
>

相关内容

  • 没有找到相关文章