How to show empty view when ListView is empty?
Posted
by
Sheehan Alam
on Stack Overflow
See other posts from Stack Overflow
or by Sheehan Alam
Published on 2010-09-22T16:40:10Z
Indexed on
2012/04/13
23:29 UTC
Read the original article
Hit count: 172
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>
© Stack Overflow or respective owner