Skip to content

Instantly share code, notes, and snippets.

@ccjeng
Last active December 26, 2015 10:00
Show Gist options
  • Save ccjeng/5b2bb1820895955c7f27 to your computer and use it in GitHub Desktop.
Save ccjeng/5b2bb1820895955c7f27 to your computer and use it in GitHub Desktop.
Android SwipeRefreshLayout Java
private SwipeRefreshLayout mSwipeLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......
mSwipeLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_container);
mSwipeLayout.setOnRefreshListener(this);
mSwipeLayout.setColorSchemeResources(android.R.color.holo_red_light,
android.R.color.holo_blue_light,
android.R.color.holo_green_light,
android.R.color.holo_orange_light);
......
}
@Override
public void onRefresh() {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
//refresh data
mSwipeLayout.setRefreshing(false);
}
}, 3000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment