How to show empty view when ListView is empty?
- by Sheehan Alam
Here is my layout.
For some reason the empty view (TextView in this case) always appears, even when the List is not empty. I thought the ListView would automatically detect when to show the empty view.
How can I hook up the empty view properly?
<RelativeLayout android:id="@+id/LinearLayoutAR"
android:layout_height="fill_parent" android:layout_width="fill_parent">
<ListView android:layout_width="fill_parent"
android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ARListView"></ListView>
<ProgressBar android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/arProgressBar"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"></ProgressBar>
<!-- Here is the view to show if the list is emtpy -->
<TextView android:id="@id/android:empty" android:layout_width="match_parent"
android:layout_height="match_parent" android:text="No Results" />
</RelativeLayout>