Android 5.0 new features learning summary under pull refresh (one)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.