从J2EE转向Android的第七天-----文件管理
2010-04-28 22:59
295 查看
先说说昨天的错误:
异常信息:java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
还是看API吧,API中这样描述:
An activity that displays a list of items by binding to a data source such as an array or Cursor, and exposes event handlers when the user selects an item.
ListActivity hosts a ListView object that can be bound to different data sources, typically either an array or a Cursor holding query results. Binding, screen layout, and row layout are discussed in the following sections
ListActivity has a default layout that consists of a single, full-screen list in the center of the screen. However, if you desire, you can customize the screen layout by setting your own view layout with setContentView() in onCreate(). To do this, your own view MUST contain a ListView object with the id "@android:id/list" (or list if it's in code)
ListActivity是一个显示数据的Activity,拥有一个listview对象用来实现数据源的绑定显示
ListActivity本身有一个默认的layout,其中包含一个全屏的list,如果使用默认的layout,则不适用setContentView方法,否则就自己建一个layout,使用setConvtentView()加载.
说下我出错的地方,layout必须有一个ListView,在我的layout中有个id为 @+id/list的ListView,但是需要的是@android:id/list的ListView.
但是@id+/list 和@android:id/list有什么区别呢?
在网上转了半天,的出的结论是:
@+id/list,会新建一个list;
@android:id/list是引用已经定义好的list,其实系统内部已经定义好了一个list
![](https://oscdn.geek-share.com/Uploads/Images/Content/202012/09/448969b693c14dd31244a5d6a5aadc6e.gif)
照着书上做了个例子。
onFocusChange,此事件在电脑pc上是鼠标滚动或按键触发,哈哈,我没android手机,悲剧,穷人啊。
为了手机奋斗。奋斗也要睡觉。睡觉。
异常信息:java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
还是看API吧,API中这样描述:
An activity that displays a list of items by binding to a data source such as an array or Cursor, and exposes event handlers when the user selects an item.
ListActivity hosts a ListView object that can be bound to different data sources, typically either an array or a Cursor holding query results. Binding, screen layout, and row layout are discussed in the following sections
ListActivity has a default layout that consists of a single, full-screen list in the center of the screen. However, if you desire, you can customize the screen layout by setting your own view layout with setContentView() in onCreate(). To do this, your own view MUST contain a ListView object with the id "@android:id/list" (or list if it's in code)
ListActivity是一个显示数据的Activity,拥有一个listview对象用来实现数据源的绑定显示
ListActivity本身有一个默认的layout,其中包含一个全屏的list,如果使用默认的layout,则不适用setContentView方法,否则就自己建一个layout,使用setConvtentView()加载.
说下我出错的地方,layout必须有一个ListView,在我的layout中有个id为 @+id/list的ListView,但是需要的是@android:id/list的ListView.
但是@id+/list 和@android:id/list有什么区别呢?
在网上转了半天,的出的结论是:
@+id/list,会新建一个list;
@android:id/list是引用已经定义好的list,其实系统内部已经定义好了一个list
![](https://oscdn.geek-share.com/Uploads/Images/Content/202012/09/448969b693c14dd31244a5d6a5aadc6e.gif)
照着书上做了个例子。
onFocusChange,此事件在电脑pc上是鼠标滚动或按键触发,哈哈,我没android手机,悲剧,穷人啊。
为了手机奋斗。奋斗也要睡觉。睡觉。
相关文章推荐
- 从J2EE转向Android的第六天-----文件管理
- 从J2EE转向Android的第九天-----文件存储
- android文件管理
- android调用系统自带的文件管理程序选择文件
- 第007课:Android中资源文件与布局管理(3)
- Android文件管理——选择程序打开文件
- Android拍照及图片裁剪、调用系统相册(兼容6.0以上权限处理及7.0以上文件管理)
- 移动混合开发之android文件管理-->flexbox,webFont。
- Android 简易文件管理模块
- Android Device Monitor 文件管理的常见问题
- 从J2EE转向Android的第三天-----Gallery,Menu
- 从J2EE转向Android的第四天-----Android Map
- Android手机文件远程管理
- Webview之H5页面调用android的图库及文件管理
- Android 内存分析方法整理和eclipse配置管理文件
- [Android] USB连接方式(设备文件管理 MTP 模式)下看不到文件的问题、文件内容没刷新的问题
- Android用File类写一个简单的文件管理软件
- 从J2EE转向Android的第二天
- ios有文件管理系统吗?自己开发的应用能不能像Android一样读取本地文件列表?
- 读《第一行代码》遇到问题2:Android Device Monitor 文件管理遇到的问题