最佳答案
我已经创建了一个像下面这样的 xml 文件:
<?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);
}
}
正如你所看到的,我没有做任何其他的事情,但是我正在犯错误:
您的内容必须有一个 ListView,其 id 属性为‘ android.R.id.list’
即使在 xml 中有 android:id="@+id/list"
行。
有什么问题吗?