Android How to customize a drop-down refresh, swipe up to load more containers

Source: Internet
Author: User

Objective

Drop-down refresh and load more, is a more commonly used list of data interaction mode.

Android provides native dropdown refresh container swiperefreshlayout, unfortunately styles cannot be customized.

So I intend to achieve a dedicated. But the drop-down refresh and swipe up, very test of the Android layout with the parent-child touch mechanism, so refer to a popular dropdown refresh project on GitHub

I chose him because it is a class that completes all of the view's adaptations, and it's very thin and powerful.

Demand

Let's refresh and load more controls on the drop-down, with the following requirements:

1: Pull down to refresh, drag to a certain distance, prompt text changes to let go refresh

2: After the refresh completes, the text becomes the refresh completes, the short stay 300 milliseconds prompts the user

3: Then linear acceleration to close the control.

4: Suitable for daytime, night mode different font color.

The final look is like this.

Brief ideas

1: drop-down refresh reference

Https://github.com/Yalantis/Phoenix

Let's streamline the code and keep only what we need.

2: Top Slide load more

We implemented this in the adapter code of the list control, with the following steps:

When you slide to the last item, insert a placeholder data into the array before starting the asynchronous request data, and the adapter is responsible for rendering it into the load style

After the request data is complete, delete the last placeholder data for the array and insert the request data into the array.

Comprehensive use down feeling very good, after all, is our own custom, use also handy, complete code reference Http://git.oschina.net/yso/CNBlogs/tree/master

Android How to customize a drop-down refresh, swipe up to load more containers

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.