您的位置:首页 > 移动开发 > Android开发

从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



照着书上做了个例子。

onFocusChange,此事件在电脑pc上是鼠标滚动或按键触发,哈哈,我没android手机,悲剧,穷人啊。

为了手机奋斗。奋斗也要睡觉。睡觉。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: