logcat的
06-02 15:53:34.742: E/Trace(1188): error opening trace file: No such file or directory (2)
06-02 15:53:36.682: D/dalvikvm(1188): GC_FOR_ALLOC freed 49K, 7% free 2539K/2708K, paused 483ms, total 484ms
06-02 15:53:36.712: I/dalvikvm-heap(1188): Grow heap (frag case) to 3.666MB for 1127536-byte allocation
06-02 15:53:36.782: D/dalvikvm(1188): GC_FOR_ALLOC freed 1K, 5% free 3639K/3812K, paused 69ms, total 69ms
06-02 15:53:36.902: D/dalvikvm(1188): GC_CONCURRENT freed <1K, 5% free 3639K/3812K, paused 15ms+42ms, total 123ms
06-02 15:53:37.672: I/Choreographer(1188): Skipped 49 frames! The application may be doing too much work on its main thread.
06-02 15:53:37.705: D/gralloc_goldfish(1188): Emulator without GPU emulation detected.
06-02 15:53:40.412: D/AndroidRuntime(1188): Shutting down VM
06-02 15:53:40.412: W/dalvikvm(1188): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
06-02 15:53:40.612: E/AndroidRuntime(1188): FATAL EXCEPTION: main
06-02 15:53:40.612: E/AndroidRuntime(1188): java.lang.RuntimeException: Unable to start activity ComponentInfo{testing.android.application.three/testing.android.application.three.MainActivityNext}: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
06-02 15:53:40.612: E/AndroidRuntime(1188): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
06-02 15:53:40.612: E/AndroidRuntime(1188): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
06-02 15:53:40.612: E/AndroidRuntime(1188): at android.app.ActivityThread.access$600(ActivityThread.java:141)
06-02 15:53:40.612: E/AndroidRuntime(1188): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
06-02 15:53:40.612: E/AndroidRuntime(1188): at android.os.Handler.dispatchMessage(Handler.java:99)
06-02 15:53:40.612: E/AndroidRuntime(1188): at android.os.Looper.loop(Looper.java:137)
06-02 15:53:40.612: E/AndroidRuntime(1188): at android.app.ActivityThread.main(ActivityThread.java:5041)
06-02 15:53:40.612: E/AndroidRuntime(1188): at java.lang.reflect.Method.invokeNative(Native Method)
06-02 15:53:40.612: E/AndroidRuntime(1188): at java.lang.reflect.Method.invoke(Method.java:511)
06-02 15:53:40.612: E/AndroidRuntime(1188): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
06-02 15:53:40.612: E/AndroidRuntime(1188): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
06-02 15:53:40.612: E/AndroidRuntime(1188): at dalvik.system.NativeStart.main(Native Method)
06-02 15:53:40.612: E/AndroidRuntime(1188): Caused by: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
06-02 15:53:40.612: E/AndroidRuntime(1188): at android.app.ListActivity.onContentChanged(ListActivity.java:243)
06-02 15:53:40.612: E/AndroidRuntime(1188): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:273)
06-02 15:53:40.612: E/AndroidRuntime(1188): at android.app.Activity.setContentView(Activity.java:1881)
06-02 15:53:40.612: E/AndroidRuntime(1188): at testing.android.application.three.MainActivityNext.onCreate(MainActivityNext.java:28)
06-02 15:53:40.612: E/AndroidRuntime(1188): at android.app.Activity.performCreate(Activity.java:5104)
06-02 15:53:40.612: E/AndroidRuntime(1188): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
06-02 15:53:40.612: E/AndroidRuntime(1188): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
06-02 15:53:40.612: E/AndroidRuntime(1188): ... 11 more
06-02 15:53:44.662: I/Process(1188): Sending signal. PID: 1188 SIG: 9
答案 0 :(得分:2)
您的问题是您正试图extends ListActivity
并且您没有ListView
android:id="android.R.id.list"
您的xml中需要ListView
id
。请将其添加到您的xml
您可以通过logcat中的以下行告诉
Caused by: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
如果您找到引用Activity
的下一行,它会告诉您班级和行号
at testing.android.application.three.MainActivityNext.onCreate(MainActivityNext.java:28)
所以MainActivityNext
第28行显示异常。
注意强>
正如评论中所述,请不要在寻求帮助时发布未格式化的logcat。请尝试查找错误发生的位置,并发布相关代码以及问题描述。这个很容易从错误中看出,但通常我们需要看一些代码
您可以使用CTRL + K格式化代码和logcat,或使用{}
上方的编码括号答案 1 :(得分:2)
您已定义了ListViewActivity(我猜),但它没有@android:id/list
。您应该像这样更改ListView的ID:
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>