Fragment loading spinner/dialog in Honeycomb
Asked Answered
M

2

7

When loading data into my Fragments I would would like to have an indeterminate spinner in the middle of the fragment (example in pic below) to show the user that content is loading within that particular pane.

What's the best way to do this in Honeycomb?

I don't really want to use a spinner in the action bar, it's not immediately obvious where data is loading. Also, I don't want an indeterminate progress dialog because it appears in the center of the entire app and also stops the user from doing anything else until it is dismissed. N.B. FragmentDialogs seem to do this also.

Am I going to have to hack around with a custom FrameLayout to get the desired effect for each pane?

honeycomb screenshot

Moberg answered 15/3, 2011 at 21:16 Comment(0)
L
18

If you're using a ListFragment you can call setListShown(false) to display a loading progress indicator until you call setListShown(true). You can call these in the fragment's Loader callback methods to show the indicator while the list is loading.

Larkin answered 25/3, 2011 at 3:23 Comment(2)
@J-Knight hey man I'm getting IllegalStateException("Can't be used with a custom content view"); when I use setListShown. I'm calling it with false in ListFragment.onActivityCreated to show progress and with true in onStart to show list and hide progress. What is the fragments Loader callback?Auctioneer
@towpse I guess the error says it all: This doesn't work with custom listView layouts. It should however work with the standard listview.Barri
C
3

I think the best way to accomplish this would be to use a ViewSwitcher. Then if you are using a loader, you can just switch between the views (the loading view and the content view) after the load has been completed.

Cruce answered 15/3, 2011 at 21:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.