即使在ListView中有記錄時,也始終顯示ListView中的emptyView。 我使用SherlockFragment和我展示ListView控件的代碼如下:即使listView中有元素,也會始終顯示listView.SeptEmptyView
ViewGroup vg = (ViewGroup) getActivity().getLayoutInflater().inflate(
R.layout.header_file, hotelListView, false);
hotelListView.addHeaderView(vg, null, false);
hotelListView.setOnItemClickListener(this);
hotelListView.setEmptyView(view.findViewById(R.id.empty));
和XML:
<ListView
android:id="@+id/hotel_list_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:cacheColorHint="#00000000"
android:paddingLeft="8dp"
android:persistentDrawingCache="scrolling"
android:scrollingCache="false" >
</ListView>
<TextView
android:id="@android:id/empty"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="No Results" />
所以以後我檢索結果形成的TextView仍顯示服務器在屏幕上,我可以看到屏幕上沒有結果文本,同時列表中有項目。我需要改變什麼,所以只有當列表中沒有元素時,纔會顯示@android:id/empty。由於
我也一直有同樣的問題。 – ddmytrenko 2013-11-11 17:57:09