初学时遇到的小问题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'
关于解决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'的更多相关文章
- 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 ...
- 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 ...
- 使用ListView 时,遇到了 Your content must have a ListView whose id attribute is 'android.R.id.list' 错误
今天在开发Android小应用的时候,使用到了ListView,在使用自己创建的listview风格的时候,就出现了如标题的错误提示信息,这个就让我纳闷了,以前也不会出现这个问题啊,而且也可以运行,赶 ...
- 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 ...
- 三行代码接入,社交软件打字时底下弹出的表情布局,自定义ViewPager+页面点标+各种功能的android小框架。
(转载请声明出处:http://www.cnblogs.com/linguanh/) 前言: 接上次分享的 ListView 动态加载类,入口:http://www.cnblogs.com/lingu ...
- 初学划分树,小见解之!POJ-2104/HDU-2665
划分树 本来是学主席树的,可怜我等巨弱观群巨博客难解fotle主席的思想精髓.于是学了一下划分树,嗯,花了一下午时间理解build(其实自己模拟一遍就通了),我很难理解为什么划分树会看不懂而能学会主席 ...
- 移除HTML5 input在type="number"时的上下小箭头
/*移除HTML5 input在type="number"时的上下小箭头*/ input::-webkit-outer-spin-button, input::-webkit-in ...
- gdb调试运行时的程序小技巧
使用gdb调试运行时的程序小技巧 标签: 未分类 gdb pstack | 发表时间:2012-10-15 04:32 | 作者:士豪 分享到: 出处:http://rdc.taobao.com/bl ...
- 关于eclipse的indigo版中文注释时字体太小的问题(转)
eclipse目前最新版代号indigo, 在win7上使用时中文注释时字体太小的问题. 为什么会这样? 首先我们应该知道, 在win7系统中, font是有"显示"和" ...
随机推荐
- C语言位操作
#include <stdio.h> void print(int); int main(void) { int flag = 0xffe4; print(flag); printf(&q ...
- module、export、require、import的使用
module 每个文件就是一个模块.文件内定义的变量.函数等等都是在自己的作用域内,都是自身所私有的,对其它文件不可见. 每个文件内部都有一个module对象,它包含以下属性 id: 模块的识别符,通 ...
- 游标的小知识(借鉴and整理)
一.游标(用来存储多条查询数据的一种数据结构(结果集),它有一个指针,用来从上往下移动,从而达到遍历每条记录的作用) 游标也可以理解为逐行返回SQL语句的结果集 如何编写一个游标? 1.声明游标 de ...
- 菱形开合的实现 IOS
实现的原理: 利用了自动布局和形变 核心代码块: @implementation JHMainView { UILabel *label1,*label2,*label3,*label4; UIBut ...
- angular指令中@,=,&的区别
当directive中的scope设置为一个对象的时候,该指令就有了一个独立的作用域,AngularJS提供了一种绑定策略用于隔离作用域和外部作用域进行通信. 1.@(or @attr) 使用@符号可 ...
- java语言编写杨辉三角
package com.llh.demo; /** * 杨辉三角 * * @author llh * */ public class Test { /* * 杨辉三角 */ public static ...
- win7旗舰版安装IIS
1.在控制面板中:程序->打开或关闭Windows功能 2.在弹出的对话窗中,在“Internet服务信息”中作如下勾选(打钩的为全选) 点击确定后安装. 3.安装成功后回到控制面板->系 ...
- 关于狄克斯特拉算法(dijkstra)总结
1,2,4是四个定点其他的是距离,从2到4最直接的就是2-4,但是不是最近的,需要舒展一下2-1-4,这样只有8.所以才是最短的.这个过程就是狄克斯特拉算法.下面进入正题: 我们这里定义图的编号为 ...
- Mongoose之 SchemaTypes 数据类型
SchemaTypes 数据类型 SchemaTypes handle definition of path defaults, validation, getters, setters, field ...
- Linux系列教程(十五)——Linux用户和用户组管理之用户管理命令
上篇博客我们介绍了用户管理的相关配置文件,包括用户信息文件/etc/passwd,用户密码文件/etc/shadow:然后介绍了用户组信息文件/etc/group,用户组密码文件/etc/gshado ...