问题提出

错误提示:Your content must have a ListView whose id attribute is 'android.R.id.list'

关于解决Your content must have a ListView whose id attribute is ‘Android.R.id.list’的问题:

很可能是因为我们要实现对ListView中setOnItemClick的事件监听而去继承了LiseActivity,但是却没有ListView的标签,解决问题方法很简单:

ListView的id设置为“@android:id/list”或android:id=”@id/android:list”

用getListView来获取ListView的对象了。

    <ListView
android:id="@android:id/list" 或android:id="@id/android:list"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</ListView>

lsitActivity的使用说明

待补充

ListActivity ListView的id为什么要用@android:id/list

关于id的知识

@+id/android:list"和"@android:id/list"的写法

2.同样容易报此错误的还有TabHost,如下:

问题1. 运行Activity的时候出现Your content must have a TabHost whose id attribute is ‘android.R.id.tabhost’

添加Layout的时候,xml跟元素选择TabHost, 但是ADT没有添加id属性, 运行的时候,会提示Your content must have a TabHost

whose id attribute is ‘android.R.id.tabhost’错误, 需要添加android:id=”@android:id/tabhost”, 这样就可以了。

问题2. 运行Activity的时候出现Your TabHost must have a TabWidget whose id attribute is ‘android.R.id.tabcontent’

解决方法: 修改FrameLayout添加id属性, ADT自动生成的xml文件中Id是android:id=”@+id/FrameLayout01 ”, 需要修改成下

面的格式android:id=”@android:id/tabcontent ”,这个估计会困扰一大批初学者,谁会想到会修改这个地方,看到错误很容易

修改成tabcontent,但是前缀不容易想到。 而且在ADT可视化编辑这个文件的时候, 界面上显示NullPointerException,这个是

ADT的一个BUG。

修改后的xml如下:

    <?xml version=”1.0″ encoding=”utf-8″?>
<TabHost
android:id=”@android:id/tabhost”
xmlns:android=”http://schemas.android.com/apk/res/android”
android:layout_width=”fill_parent” android:layout_height=”fill_parent”>
<LinearLayout android:id=”@+id/LinearLayout01″ android:layout_height=”fill_parent”
android:layout_width=”fill_parent” android:orientation=”vertical”>
<TabWidget android:id=”@android:id/tabs” android:layout_height=”wrap_content”
android:layout_width=”fill_parent”>
</TabWidget>
<FrameLayout android:id=”@android:id/tabcontent” android:layout_width=”fill_parent”
android:layout_height=”fill_parent”>
</FrameLayout>
</LinearLayout>
</TabHost>

注意: 如果用TabHost的话, 上面标红的三处必须是一样, 这个是Google的约定。 而且一个工程中只能有一个TabHost。

来源:http://blog.csdn.net/yg6111/article/details/6908251

http://blog.sina.com.cn/s/blog_94103cd90100zokn.html

相关链接 >

Android中 Your content must have a ListView whose id attribute is 'android.R.id.list'错误的解决办法

使用ListView 时,遇到了 Your content must have a ListView whose id attribute is 'android.R.id.list' 错误

Your content must have a ListView whose id attribute is android.R.id.list和ListView注意

初学时遇到的小问题Your content must have a ListView whose id attribute is 'android.R.id.list'的更多相关文章

  1. Andriod学习笔记2:“Your content must have a ListView whose id attribute is 'android.R.id.list'”问题的解决办法

    问题描述 activity_main.xml代码如下: <?xml version="1.0" encoding="utf-8"?> <Lin ...

  2. Android Your content must have a ListView whose id attribute is 'android.R.id.list'错误的解决办法

    在Android开发中,ListView有着很重要的地位,使用的场合也非常的多 错误提示:Your content must have a ListView whose id attribute is ...

  3. 使用ListView 时,遇到了 Your content must have a ListView whose id attribute is 'android.R.id.list' 错误

    今天在开发Android小应用的时候,使用到了ListView,在使用自己创建的listview风格的时候,就出现了如标题的错误提示信息,这个就让我纳闷了,以前也不会出现这个问题啊,而且也可以运行,赶 ...

  4. Your content must have a ListView whose id attribute is 'android.R.id.list'

    修改ListView的ID为 ' @android:id/list ' <ListView android:id="@android:id/list" android:lay ...

  5. 三行代码接入,社交软件打字时底下弹出的表情布局,自定义ViewPager+页面点标+各种功能的android小框架。

    (转载请声明出处:http://www.cnblogs.com/linguanh/) 前言: 接上次分享的 ListView 动态加载类,入口:http://www.cnblogs.com/lingu ...

  6. 初学划分树,小见解之!POJ-2104/HDU-2665

    划分树 本来是学主席树的,可怜我等巨弱观群巨博客难解fotle主席的思想精髓.于是学了一下划分树,嗯,花了一下午时间理解build(其实自己模拟一遍就通了),我很难理解为什么划分树会看不懂而能学会主席 ...

  7. 移除HTML5 input在type="number"时的上下小箭头

    /*移除HTML5 input在type="number"时的上下小箭头*/ input::-webkit-outer-spin-button, input::-webkit-in ...

  8. gdb调试运行时的程序小技巧

    使用gdb调试运行时的程序小技巧 标签: 未分类 gdb pstack | 发表时间:2012-10-15 04:32 | 作者:士豪 分享到: 出处:http://rdc.taobao.com/bl ...

  9. 关于eclipse的indigo版中文注释时字体太小的问题(转)

    eclipse目前最新版代号indigo, 在win7上使用时中文注释时字体太小的问题. 为什么会这样? 首先我们应该知道, 在win7系统中, font是有"显示"和" ...

随机推荐

  1. Rolling Hash(Rabin-Karp算法)匹配字符串

    您可以在我的个人博客中访问此篇文章: http://acbingo.cn/2015/08/09/Rolling%20Hash(Rabin-Karp%E7%AE%97%E6%B3%95)%E5%8C%B ...

  2. VIM文本替换命令

    在VIM中进行文本替换:       1.  替换当前行中的内容:    :s/from/to/    (s即substitude)         :s/from/to/     :  将当前行中的 ...

  3. word2vec 在 非 自然语言处理 (NLP) 领域的应用

    word2vec 本来就是用来解决自然语言处理问题的,它在 NLP 中的应用是显然的. 比如,你可以直接用它来寻找相关词.发现新词.命名实体识别.信息索引.情感分析等:你也可以将词向量作为其他模型的输 ...

  4. Android 6.0 双向通话自动录音

    package com.example.hgx.phoneinfo60.Recording; import android.content.BroadcastReceiver; import andr ...

  5. NOIP2012疫情控制(二分答案+倍增+贪心)

    Description H国有n个城市,这n个城市用n-1条双向道路相互连通构成一棵树,1号城市是首都,也是树中的根节点. H国的首都爆发了一种危害性极高的传染病.当局为了控制疫情,不让疫情扩散到边境 ...

  6. C# 使用OpenCV在一张图片里寻找人脸

    先上个效果图 相关库的下载 例程中用到一个库叫做emgucv,是opencv\的net封装 编译打包好的稳定版,在这:https://sourceforge.net/projects/emgucv/f ...

  7. angular核心$watch,$digest,$apply之间的联系

    浏览器事件发生时,会在浏览器的上下文window中执行,而angular有自己的上下文angular content,angular 事件在自己的上下文angular content中执行. $wat ...

  8. java语言在某个数组中查找某个字符出现的次数

    package com.llh.demo; import java.util.Scanner; /** * * @author llh * */ public class Test { /* * 在某 ...

  9. Restaurant

    Restaurant Time Limit:4000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit  ...

  10. Scala从入门到精通之四-映射和元组

    在Scala中映射之键值对的集合,元组是n个对象的聚集,但是对象的类型不一定相同 本节内容要点 Scala中映射的创建,遍历和查询 如何从可变和不可变映射中做出选择 Scala映射和Java映射见的互 ...