问题提出

错误提示: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. JQuery-基础学习1

    1)JQuery语法 jquery语法是为HTML元素的选取编制,可以对元素执行某些操作. 基础语法是:$(selector).action() 美元符号定义JQuery 选择符(selector)& ...

  2. JAVA基础-XML的解析

    一.XML的概述 XML的全名为可扩展标记语言(Extensible Markup Language),XML的作用为:1.传输,2.存取数据,3.软件的配置文件.传输现在都用更轻量的Json,而存储 ...

  3. sql执行报错--This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'

    问题: 不支持使用 LIMIT 子句的 IN/ALL/ANY/SOME 子查询,即是支持非 IN/ALL/ANY/SOME 子查询的 LIMIT 子查询. 解决: 将语句:select * from ...

  4. mybatis xml中使用where 条件中的in方法

    <select id="queryCount" resultType="cn.bnsr.edu_yun.view.FileView"> SELECT ...

  5. MongoDB自动增长

    MongoDB 没有像SQL一样有自动增长的功能,如果我们需要实现ObjectId自动增长功能,可以通过编程的方式来实现.步骤如下: 1. 创建counters集合: db.createCollect ...

  6. LeetCode 226. Invert Binary Tree (反转二叉树)

    Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3 1 Trivia:This problem was ...

  7. LeetCode 79. Word Search(单词搜索)

    Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from l ...

  8. 正则表达式&常用JS校验

    符号 含义 ^ 以什么开头 $ 以什么结束 * 任意个(包括0个) + 至少一个 ? 没有或一个 {a,b} a-b个 {a} 正好a个 {a,} 至少a个 | 或 . 任意字符 [] 方括号内的任意 ...

  9. 笔记-java泛型详解

    首先,先说明一下,java泛型文章的出处:http://www.cnblogs.com/lzq198754/p/5780426.html 作为学习笔记保存. 1.为什么需要泛型 泛型在Java中有很重 ...

  10. bug:论用例健壮性的重要

    最近出了2个类似问题,此处写下,以作为警醒 问题1: 背景:电商类网站,为了增加用户回流,增加用户购买力度,做了一个和用户等级相关活动 需求:用户等级为g0 -g5,现在有一批代金券有等级领取限制.用 ...