after Android 5.0 Google finally added a drop-down refresh control under the support V4 package
Project Address:Https://github.com/stormzhang/SwipeRefreshLayoutDemo
Xml:<android.support.v4.widget.swiperefreshlayout xmlns:android= "Http://schemas.android.com/apk/res/android"
Android:id= "@+id/swipe_container"
Android:layout_width= "Match_parent"
android:layout_height= "Match_parent" >
<listview
Android:id= "@+id/listview"
Android:layout_width= "Match_parent"
android:layout_height= "Wrap_content"
android:padding= "16DP"/>
</android.support.v4.widget.swiperefreshlayout>java: Implement monitoring:
ImplementsSwiperefreshlayout.onrefreshlistener
/** method in listener Swiperefreshlayout.onrefreshlistener, trigger after pull refresh*/ Public voidOnrefresh () {NewHandler (). postdelayed (NewRunnable () {@Override Public voidrun () {//Stop RefreshMswipelayout.setrefreshing (false); } }, 5000);//send message after 5 seconds, stop refresh} Initialize the drop-down refresh control Mswipelayout = (swiperefreshlayout) Findviewbyid (R.id.swipe_container); Mswipelayout.setonrefreshlistener (this);//Set the color on the drop-down circle, blue, green, orange, Red mswipelayout.setcolorschemeresources (Android. R.color.holo_blue_bright, Android. R.color.holo_green_light,android. R.color.holo_orange_light, Android. R.color.holo_red_light); Mswipelayout.setdistancetotriggersync (400);// Setting how much distance your finger pulls down on the screen will trigger a drop-down refresh Mswipelayout.setprogressbackgroundcolor (r.color.red); Sets the background mswipelayout.setsize of the drop-down circle (Swiperefreshlayout.large); Set the size of a circle
Official documents:Https://developer.android.com/reference/android/support/v4/widget/SwipeRefreshLayout.html
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Android 5.0 new features learning summary under pull refresh (one)