KVISH KVISH - 9 months ago 38
Android Question

SwipeRefreshLayout in API 21

I previously was using API 19 and was using

for many of my fragments. When I loaded content for the first time previously, I was using the
and was able to load content and it worked fine.

I'm noticing in Android 5.0 Google is using a circular progress view. When I call
now it simply has no effect. Is there anyway to programmatically show the new spinner? I've delved in to this quite a bit but not able to programmatically show it. I have read the following on this:



SwipeRefreshLayout doesn't show any indicator of refreshing

Basically, it shows no indication of refreshing on the first try.


Instead of directly setting


you can delay it on the UI thread for later

getSwipeRefreshLayout().post(new Runnable() {
    @Override public void run() {

this works perfectly for me to start loading in onCreateView and if done in a LoaderManager.LoaderCallbacks too.

I haven't seen the progress bar accidentally sticking (because the data load is too quick), but if you suspect that the load may return too early (error?) it's worth to do the same posting for


this way the two posts will definitely come one after the other, resulting in a definitely hidden progress view.