Remove loading spinner in SwipeRefreshLayout
Asked Answered
H

5

39

I use a SwipeRefreshLayout to reload the content of a listview. It works and the onRefreshListener is triggered but the small loading spinner that appears onswipe doesn't want to dismiss after the loading is complete. Is there a way to make it go ?

Edit : fixed SwipeView means SwipeRefreshLayout

Hagiarchy answered 18/2, 2015 at 11:30 Comment(0)
S
56

Do you mean SwipeRefreshLayout? if so use SwipeRefreshLayout.setRefreshing(false)

Sinistrality answered 18/2, 2015 at 11:35 Comment(2)
Yes it was what i meant. I corrected the View name mistake in the op. Thank you your solution works!Hagiarchy
I have this scenario, getting JSON data from server. And how to test if it is already loaded so that SRL can be dismiss - set to falseEpergne
V
28

The correct way of using it is like this:

if (swipeLayout.isRefreshing()) {
   swipeLayout.setRefreshing(false);
}
Viridis answered 18/2, 2015 at 12:18 Comment(0)
H
9

If you are using SwipeRefreshLayout then use swipeLayout_object.setRefreshing(false); for dismiss that loading icon. i.e.

private SwipeRefreshLayout swipeLayout;

protected void onCreate(Bundle savedInstanceState) {
....


 swipeLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_container);

 swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

                @Override
                public void onRefresh() {
                    //Do your task
                    swipeLayout.setRefreshing(false);

                }
            });
}

Details available here. https://developer.android.com/reference/android/support/v4/widget/SwipeRefreshLayout.html

Hoang answered 18/2, 2015 at 11:47 Comment(0)
P
6

For Kotlin,

SwipeRefreshLayout.isRefreshing = false

Phyllys answered 8/1, 2020 at 7:26 Comment(0)
K
1

here is complete solution for loading a page and remove loading animation after page is fully loaded.

 private class CustomWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
    view.loadUrl(url);
    return true;
}

@Override
public void onPageFinished(WebView view, String url) {
    swipeRefreshLayout.setRefreshing(false);
}
Kef answered 28/1, 2018 at 20:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.