Is there any way to trigger the SwipeRefreshLayout
programmatically? The animation should start and the onRefresh
method from the OnRefreshLi
Simply create a SwipeRefreshLayout.OnRefreshListener
and call its function onRefresh()
whenever needed:
SwipeRefreshLayout srl;
SwipeRefreshLayout.OnRefreshListener refreshListener;
srl = (SwipeRefreshLayout)v.findViewById(R.id.swipeRefreshLayout);
refreshListener = new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
//Do your stuff here
}
};
srl.setOnRefreshListener(refreshListener);
Now, whenever you want to call it manually, just call it through the listener
refreshListener.onRefresh();