Google pull-down refresh component --- SwipeRefreshLayout

Source: Internet
Author: User

Today, I saw the term SwipeRefreshLayout on Google +. I searched for it and found that it was a new widget added to the google update sdk, so I had to learn it first.

SwipeRefreshLayout

SwipeRefreshLayout literally refers to the pull-down refresh layout, inherited from ViewGroup, under the support v4 compatibility package, but you must upgrade your support library version to 19.1. When it comes to pull-down refresh, everyone must be familiar with ActionBarPullToRefresh. Now google has launched a more official pull-down refresh component, which is undoubtedly a good news for developers. You can use this component to easily refresh Google Now. For details, see:

Main Method

  • SetOnRefreshListener (OnRefreshListener): adds a Listener for the layout.
  • SetRefreshing (boolean): display or hide the refresh progress bar
  • IsRefreshing (): checks whether a refresh status is in progress.
  • SetColorScheme (): Set the color topic of the progress bar. You can set up to four

Xml layout File

The layout file is simple. You only need to add SwipeRefreshLayout to the outermost layer, and then its child is a scrollable view, such as ScrollView or ListView. For example, copy the code

Activity Code

Copy code

 

The above code is very simple. You only need to add a listener to SwipeRefreshLayout. It is worth noting that the setColorScheme method sets the color of the refresh progress bar and can only set up to four types of loop display, the first one by default is the color progress bar loaded with user gestures.

Source code

The demo is written on github at: SwipeRefreshLayoutDemo.

Summary

Google is constantly improving its own sdk and launching more and more components. The goal is to make development simpler and design more unified. This may be the future direction of google, this is undoubtedly a good news for developers.

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.