Niklas Niklas - 1 year ago 313
Android Question

SwipeRefreshLayout trigger programmatically

Is there any way to trigger the

programmatically? The animation should start and the
method from the
interface should get called.

Answer Source

if you are using the new swipeRefreshLayout intoduced in 5.0 enter image description here

As the image shown above you just need to add the following line to trigger the swipe refresh layout programmatically Runnable() {
        public void run() {

if you simply call


it won't trigger the circle to animate, so by adding the above line u just make a delay in the UI thread so that it shows the circle animation inside the ui thread.

By calling mSwipeRefreshLayout.setRefreshing(true) the OnRefreshListener will NOT get executed

In order to stop the circular loading animation call mSwipeRefreshLayout.setRefreshing(false)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download