Search code examples
androidactionbarsherlock

How can I bring back the load indicator in the (sherlock) listview when refreshing?


Observe the image below. This is displayed in place of the ListView data before I set the ListAdapter in my SherlockListFragment. I don't know if this is a product of SherlockActionBar or standard Android, but in any case - how do I bring it back at a later point? My use case is that I have a refresh button and when the user presses that I want the list to clear and the spinner to appear again while loading.

Image of load indicator (spinner)


Solution

  • In your SherlockListFragment, call setListShown(false);

    The documentation for the compatibility ListFragment (which SherlockListFragment extends from) states:

    Control whether the list is being displayed. You can make it not displayed if you are waiting for the initial data to show in it. During this time an indeterminant progress indicator will be shown instead.

    Then of course, once you finish refreshing, call setListShown(true);