swipeRefreshLayout in a different activity code example
Example: SwipeRefreshLayout
public class ActivityMain extends FragmentActivity implements OnRefreshListener {
private SwipeRefreshLayout mSwipeRefreshLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_main);
mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.container);
mSwipeRefreshLayout.setOnRefreshListener(this);
super.onCreate(savedInstanceState);
}
@Override
public void onRefresh() {
Toast.makeText(this, "Refresh", Toast.LENGTH_SHORT).show();
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
mSwipeRefreshLayout.setRefreshing(false);
}
}, 2000);
}
}