其实应该吧emptyView放在 listView的下面
<!--
The frame layout is here since we will be showing either
the empty view or the list view.
-->
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1" >
<!--
Here is the list. Since we are using a ListActivity, we
have to call it "@android:id/list" so ListActivity will
find it
-->
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:drawSelectorOnTop="false" />
<TextView
android:id="@+id/empty"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/list_8_no_photos" />
</FrameLayout>然后list.setEmptyView(findViewById(R.id.empty));
list有数据的时候 textView不会显示 否则就会显示那个 空View
本文介绍了一种在Android中设置ListView空视图的方法。通过使用FrameLayout布局将ListView与空状态提示TextView组合在一起,并通过调用setEmptyView()方法来控制空视图的显示与隐藏。
1050

被折叠的 条评论
为什么被折叠?



