views:

120

answers:

3

My app connects to the net and populates a ListView. Sometimes nothing will be returned. What is the best way to notify the user the list is empty?

Some of my own suggestions:

  • Show "No Results" in the first ListItem
  • Show a new view that says "No Results"
+2  A: 

Show a new view that says "No Results"

This is the correct option. Do not confuse your user by presenting an info message as a list item. They are not the same.

Synesso
A: 

I choose "Show "No Results" in the first ListItem".

Because users could connect the "No Results" to the ListItem directly, while new view leads users to have to accept new thing.

卢声远 Shengyuan Lu
+6  A: 

ListView allows you to have an alternative view shown when it is empty:

http://developer.android.com/reference/android/widget/AdapterView.html#setEmptyView(android.view.View)

In fact, if you use a ListActivity whose layout has a view with android:id="@android:id/empty", it will automatically hook this up for you.

So typically you could put the ListView and your empty view in a FrameLayout, and have the empty view have some nice text centered in its area telling the user there is nothing to show.

hackbod