在 Android 中自定义了一个 ListView 布局。使用的下面的代码:
public class CheckInList extends ListActivity {
...
@Override
public void onCreate(Bundle savedInstanceState) {
...
mAdapter = new ArrayAdapter<String>(this, R.layout.checkinlist_item, R.id.checkinlist_item_text, mNames);
setListAdapter(mAdapter);
...
}
}
checkinlist_item.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/checkinlist_item_bg">
<TextView android:id="@+id/checkinlist_item_text"
style="@style/RegisterText" />
</RelativeView>
如果我使用 android.R.layout.simple_list_item_1 来代替上面的模版,程序可以正常运行。然而当我使用上面的代码,activity 就会奔溃。上面的程序是在 Android 1.5 上运行的。
为什么 activity 会崩溃呢?