我已经创建了一个XML文件是这样的:
I have created an xml file like this:
<?xml version="1.0" encoding="utf-8"?>
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/list" >
</ListView>
和活动:
public class ExampleActivity extends ListActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mainlist);
}
}
正如你看到的,我没有做任何东西。但我'收到错误:
As you see, I have not done anything else. But I'am getting the error:
您的内容必须有一个ListView,其id属性是'android.R.id.list
Your content must have a ListView whose id attribute is 'android.R.id.list'
尽管我有机器人:ID在我的xml =@ + ID /列表
行。
这是什么问题?
重命名你的ListView像这样的ID,
Rename the id of your ListView like this,
<ListView android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
由于您使用的 ListActivity
XML文件必须指定关键字的机器人的同时提一个ID。
Since you are using ListActivity
your xml file must specify the keyword android while mentioning to a ID.
如果您需要自定义的ListView
则 ListActivity
,你要简单地扩展了活动
,应该有相同的ID不包含此关键字的机器人的。
If you need a custom ListView
then instead of Extending a ListActivity
, you have to simply extend an Activity
and should have the same id without the keyword android.