Explore the Android Open source project Pulltorefresh implementation principle

Source: Internet
Author: User

1, due to the project needs, need to achieve a more personalized pull-down refresh effect, at this time, will only use the most popular Android open source Pulltorefresh pull refresh is not enough, at the same time, in order to save development times, the new development of pull refresh and need a certain time, at this time, The best solution is to explore the implementation principle from the Pulltorefresh source point of view and modify it on the basis of the source code and achieve the desired functional effect.

2, analysis of a class, inevitably first look at the inheritance of the class.

The parent class has a linearlayout, and uses the generic T, can guess, the implementation of the drop-down refresh is a linearlayout inside including a want to pull the refresh of the ListView or GridView, when the refresh shows the top or bottom of the refresh effect is good.

3, from the top-level of the parent class down analysis.

(1) Pulltorefreshbase<t>:

 Public Abstract class extends extends Implements Ipulltorefresh<t>

This class implements the interface Ipulltorefresh:

(2) Pulltorefreshbase:

There is a variable T mrefreshableview in this class, which is used to store a control that can be pulled down and refreshed.

Private Loadinglayout mheaderlayout;
Private Loadinglayout mfooterlayout;

These two variables hold the layout of the head refresh (drop-down refresh) and the trailing flush (pull-up refresh) layout.

Private Framelayout Mrefreshableviewwrapper; Contains the layout of the Refreshableview.

Explore the Android Open source project Pulltorefresh implementation principle

Related Article

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.