您的内容必须有一个ListView扩展ListActivity时,其ID属性为'android.R.id.list“ [英] Your content must have a ListView whose id attribute is 'android.R.id.list' when extending ListActivity

查看:103
本文介绍了您的内容必须有一个ListView扩展ListActivity时,其ID属性为'android.R.id.list“的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

LogCat中

  06-02 15:53:34.742:E /跟踪(1188):错误打开跟踪文件:没有这样的文件或目录(2)
06-02 15:53:36.682:D / dalvikvm(1188):GC_FOR_ALLOC释放49K,7%免费2539K / 2708K,暂停483ms,总484ms
06-02 15:53:36.712:I / dalvikvm堆(1188):成长堆(破片的情况下),以3.666MB为1127536字节分配
06-02 15:53:36.782:D / dalvikvm(1188):GC_FOR_ALLOC释放1K,5%的游离3639K / 3812K,暂停69ms,共69ms
06-02 15:53:36.902:D / dalvikvm(1188):GC_CONCURRENT释放< 1K,5%的游离3639K / 3812K,暂停为15ms + 42ms,总123ms
06-02 15:53:37.672:I /编舞(1188):跳过49帧!该应用程序可能会做它的主线程的工作太多了。
06-02 15:53:37.705:D / gralloc_goldfish(1188):没有GPU的仿真模拟器检测。
06-02 15:53:40.412:D / AndroidRuntime(1188):关闭虚拟机
06-02 15:53:40.412:W / dalvikvm(1188):主题ID = 1:螺纹退出与未捕获的异常(组= 0x40a71930)
06-02 15:53:40.612:E / AndroidRuntime(1188):致命异常:主要
06-02 15:53:40.612:E / AndroidRuntime(1188):java.lang.RuntimeException的:无法启动的活动ComponentInfo {testing.android.application.three / testing.android.application.three.MainActivityNext}:java.lang中.RuntimeException:您的内容必须有一个ListView,其id属性是'android.R.id.list
06-02 15:53:40.612:E / AndroidRuntime(1188):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
06-02 15:53:40.612:E / AndroidRuntime(1188):在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
06-02 15:53:40.612:E / AndroidRuntime(1188):在android.app.ActivityThread.access $ 600(ActivityThread.java:141)
06-02 15:53:40.612:E / AndroidRuntime(1188):在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1234)
06-02 15:53:40.612:E / AndroidRuntime(1188):在android.os.Handler.dispatchMessage(Handler.java:99)
06-02 15:53:40.612:E / AndroidRuntime(1188):在android.os.Looper.loop(Looper.java:137)
06-02 15:53:40.612:E / AndroidRuntime(1188):在android.app.ActivityThread.main(ActivityThread.java:5041)
06-02 15:53:40.612:E / AndroidRuntime(1188):在java.lang.reflect.Method.invokeNative(本机方法)
06-02 15:53:40.612:E / AndroidRuntime(1188):在java.lang.reflect.Method.invoke(Method.java:511)
06-02 15:53:40.612:E / AndroidRuntime(1188):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:793)
06-02 15:53:40.612:E / AndroidRuntime(1188):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
06-02 15:53:40.612:E / AndroidRuntime(1188):在dalvik.system.NativeStart.main(本机方法)
06-02 15:53:40.612:E / AndroidRuntime(1188):java.lang.RuntimeException的:你的内容必须有一个ListView,其id属性是'android.R.id.list产生的原因
06-02 15:53:40.612:E / AndroidRuntime(1188):在android.app.ListActivity.onContentChanged(ListActivity.java:243)
06-02 15:53:40.612:E / AndroidRuntime(1188):在com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:273)
06-02 15:53:40.612:E / AndroidRuntime(1188):在android.app.Activity.setContentView(Activity.java:1881)
06-02 15:53:40.612:E / AndroidRuntime(1188):在testing.android.application.three.MainActivityNext.onCreate(MainActivityNext.java:28)
06-02 15:53:40.612:E / AndroidRuntime(1188):在android.app.Activity.performCreate(Activity.java:5104)
06-02 15:53:40.612:E / AndroidRuntime(1188):在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
06-02 15:53:40.612:E / AndroidRuntime(1188):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
06-02 15:53:40.612:E / AndroidRuntime(1188):11 ...更多
06-02 15:53:44.662:I /过程(1188):发送信号。 PID:1188 SIG:9
 

解决方案

您的问题是你正试图扩展ListActivity ,你没有一个的ListView

 机器人:ID =android.R.id.list
 

您需要有一个的ListView 在XML与 ID 。请把它添加到您的XML

您可以通过下面一行在你的logcat告诉

 产生的原因:java.lang.RuntimeException的:你的内容必须有一个ListView,其id属性是'android.R.id.list
 

如果你发现引用您的活动的下一行它会告诉你它的类和行号

 在testing.android.application.three.MainActivityNext.onCreate(MainActivityNext.java:28)
 

所以 MainActivityNext 线图28是例外。

注意

正如评论指出,请你寻求帮助时,不只是发布格式化logcat的。请尽量寻找到错误的发生,并张贴有关code一起的问题是什么的描述。这一次很容易从错误中看到,但通常情况下我们需要看到一些code

您可以使用CTRL + K格式化您的code和logcat中也可以使用上面{}

编码支架

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

解决方案

Your problem is you are trying to extends ListActivity and you don't have a ListView with

android:id="android.R.id.list"

You need to have a ListView in your xml with that id. Please add it to your xml

You can tell by the following line in your logcat

Caused by: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'

If you find the next line that references your Activity it will tell you the class and line number

at testing.android.application.three.MainActivityNext.onCreate(MainActivityNext.java:28)

So MainActivityNext line 28 is showing the exception.

Note

As stated in a comment, please don't just post unformatted logcat when asking for help. Please try to look for where the error is occurring and post relevant code along with a description of what the problem is. This one was easy to see from the error but usually we will need to see some code

You can use CTRL+K to format your code and logcat or use the coding brackets above {}

这篇关于您的内容必须有一个ListView扩展ListActivity时,其ID属性为'android.R.id.list“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆