继承了 ListActivity 时 ,直接在布局文件中添加
< ListView
android:id ="@android:id/list"
android:layout_width ="match_parent"
android:layout_height ="match_parent" />
< TextView
android:id ="@android:id/empty"
android:layout_width ="match_parent"
android:layout_height ="match_parent"
android:gravity ="center"
android:text ="No items." />
没有继承时,在代码中设置数据为空时的view
mListView = (ListView) findViewById(R.id.List); mListView.setEmptyView(findViewById(R.id.emptyView));