当前位置: 代码迷 >> 综合 >> ApiDemo学习 setEmptyView的用法
  详细解决方案

ApiDemo学习 setEmptyView的用法

热度:1   发布时间:2024-01-21 15:46:47.0

其实应该吧emptyView放在 listView的下面 

  <!--The frame layout is here since we will be showing eitherthe empty view or the list view.--><FrameLayoutandroid:layout_width="match_parent"android:layout_height="0dip"android:layout_weight="1" ><!--Here is the list. Since we are using a ListActivity, wehave to call it "@android:id/list" so ListActivity willfind it--><ListViewandroid:id="@android:id/list"android:layout_width="match_parent"android:layout_height="match_parent"android:drawSelectorOnTop="false" /><TextViewandroid: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