Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove loading spinner in SwipeRefreshLayout

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

like image 617
Labe Avatar asked Feb 18 '15 11:02

Labe


5 Answers

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

like image 184
MineConsulting SRL Avatar answered Oct 01 '22 04:10

MineConsulting SRL


The correct way of using it is like this:

if (swipeLayout.isRefreshing()) {
   swipeLayout.setRefreshing(false);
}
like image 30
dvs Avatar answered Oct 01 '22 03:10

dvs


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

like image 22
Mukesh Kumar Singh Avatar answered Oct 01 '22 05:10

Mukesh Kumar Singh


For Kotlin,

SwipeRefreshLayout.isRefreshing = false

like image 33
iCantC Avatar answered Oct 01 '22 04:10

iCantC


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);
}
like image 29
Ehsan Rafique Avatar answered Oct 01 '22 03:10

Ehsan Rafique