1public class ActivityMain extends FragmentActivity implements OnRefreshListener {
2
3 private SwipeRefreshLayout mSwipeRefreshLayout;
4
5 @Override
6 protected void onCreate(Bundle savedInstanceState) {
7 setContentView(R.layout.activity_main);
8 mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.container);
9 mSwipeRefreshLayout.setOnRefreshListener(this);
10
11 super.onCreate(savedInstanceState);
12 }
13
14 @Override
15 public void onRefresh() {
16 Toast.makeText(this, "Refresh", Toast.LENGTH_SHORT).show();
17 new Handler().postDelayed(new Runnable() {
18 @Override
19 public void run() {
20 mSwipeRefreshLayout.setRefreshing(false);
21 }
22 }, 2000);
23 }
24}
25