为什么我的Andr​​oid应用程序一直告诉我,我需要的时候已经定义它来定义一个ListView ID? [英] Why does my Android app keep telling me I need to define a ListView id when it is already defined?

查看:112
本文介绍了为什么我的Andr​​oid应用程序一直告诉我,我需要的时候已经定义它来定义一个ListView ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我尝试运行我的应用程序,以下抛出异常:

Whenever I try to run my app, the following exception is thrown:

01-22 00:40:51.868:ERROR / AndroidRuntime(2219):了java.lang.RuntimeException:无法启动活动ComponentInfo {[绝密]}了java.lang.RuntimeException:您的内容必须有一个ListView的ID属性是'android.R.id.list

01-22 00:40:51.868: ERROR/AndroidRuntime(2219): java.lang.RuntimeException: Unable to start activity ComponentInfo{[Redacted]}: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'

下面是有问题的ListView中的标记:

Here is the markup for the ListView in question:

<ListView 
 android:id="@+id/list" 
 android:layout_width="fill_parent" 
 android:layout_height="fill_parent"
 android:dividerHeight="1px"></ListView>

所以,因为ID被明确定义为列表中,这里是什么给了?我已经通过我的code多次在过去的几个小时试图追查这个原因跑,我难住了。任何人都可以提供任何指针?

So, since the id is clearly defined as "list," what gives here? I've run through my code multiple times in the past couple of hours trying to track down the cause of this and I'm stumped. Can anyone offer any pointers?

推荐答案

也许你的类 ComponentInfo 是扩展 ListActivity 因此确保你的的ListView 对象必须在您的布局XML文件中的以下属性:

Probably your class ComponentInfo is extending the ListActivity therefore insure that your ListView object must have the following attribute in your layout XML file:

android:id="@android:id/list"

这篇关于为什么我的Andr​​oid应用程序一直告诉我,我需要的时候已经定义它来定义一个ListView ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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